diff --git a/ChangeLog.md b/ChangeLog.md
new file mode 100644
--- /dev/null
+++ b/ChangeLog.md
@@ -0,0 +1,5 @@
+# Changelog for hgdal
+
+## 1.0.0.0
+
+* Initial release
diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,25 @@
+The following license covers this documentation, and the source code, except
+where otherwise indicated.
+
+Copyright 2019-2022, Ian-Woo Kim. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/csrc/HGDALGDALDataset.cpp b/csrc/HGDALGDALDataset.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALGDALDataset.cpp
@@ -0,0 +1,26 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRLayer.h"
+
+#include "HGDALGDALMajorObject.h"
+
+#include "gdal_priv.h"
+
+#include "HGDALGDALDataset.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+GDALMAJOROBJECT_DEF_VIRT(GDALDataset)
+DELETABLE_DEF_VIRT(GDALDataset)
+GDALDATASET_DEF_VIRT(GDALDataset)
+GDALDATASET_DEF_NONVIRT(GDALDataset)
+GDALDATASET_DEF_ACCESSOR(GDALDataset)
+
diff --git a/csrc/HGDALGDALDataset.h b/csrc/HGDALGDALDataset.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALGDALDataset.h
@@ -0,0 +1,56 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALGDALMajorObject.h"
+
+#include "STDDeletable.h"
+
+
+#define GDALDATASET_DECL_VIRT(Type) \
+OGRLayer_p Type##_GetLayer ( Type##_p p, int iLayer );\
+int Type##_GetLayerCount ( Type##_p p );
+
+
+#define GDALDATASET_DECL_NONVIRT(Type) \
+
+
+
+#define GDALDATASET_DECL_ACCESSOR(Type) \
+
+
+
+#define GDALDATASET_DEF_VIRT(Type) \
+OGRLayer_p Type##_GetLayer ( Type##_p p, int iLayer ) {\
+return from_nonconst_to_nonconst<OGRLayer_t, OGRLayer>((OGRLayer*)((TYPECASTMETHOD(Type, GetLayer, GDALDataset))(p))->GetLayer(iLayer));\
+}\
+\
+int Type##_GetLayerCount ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, GetLayerCount, GDALDataset))(p))->GetLayerCount();\
+}
+
+
+#define GDALDATASET_DEF_NONVIRT(Type) \
+
+
+
+#define GDALDATASET_DEF_ACCESSOR(Type) \
+
+
+
+GDALMAJOROBJECT_DECL_VIRT(GDALDataset)
+DELETABLE_DECL_VIRT(GDALDataset)
+GDALDATASET_DECL_VIRT(GDALDataset)
+GDALDATASET_DECL_NONVIRT(GDALDataset)
+GDALDATASET_DECL_ACCESSOR(GDALDataset)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALGDALMajorObject.cpp b/csrc/HGDALGDALMajorObject.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALGDALMajorObject.cpp
@@ -0,0 +1,23 @@
+
+#include "MacroPatternMatch.h"
+
+#include "STDDeletable.h"
+
+#include "gdal_priv.h"
+
+#include "HGDALGDALMajorObject.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+DELETABLE_DEF_VIRT(GDALMajorObject)
+GDALMAJOROBJECT_DEF_VIRT(GDALMajorObject)
+GDALMAJOROBJECT_DEF_NONVIRT(GDALMajorObject)
+GDALMAJOROBJECT_DEF_ACCESSOR(GDALMajorObject)
+
diff --git a/csrc/HGDALGDALMajorObject.h b/csrc/HGDALGDALMajorObject.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALGDALMajorObject.h
@@ -0,0 +1,48 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "STDDeletable.h"
+
+#include "stdcxxType.h"
+
+
+#define GDALMAJOROBJECT_DECL_VIRT(Type) \
+
+
+
+#define GDALMAJOROBJECT_DECL_NONVIRT(Type) \
+
+
+
+#define GDALMAJOROBJECT_DECL_ACCESSOR(Type) \
+
+
+
+#define GDALMAJOROBJECT_DEF_VIRT(Type) \
+
+
+
+#define GDALMAJOROBJECT_DEF_NONVIRT(Type) \
+
+
+
+#define GDALMAJOROBJECT_DEF_ACCESSOR(Type) \
+
+
+
+DELETABLE_DECL_VIRT(GDALMajorObject)
+GDALMAJOROBJECT_DECL_VIRT(GDALMajorObject)
+GDALMAJOROBJECT_DECL_NONVIRT(GDALMajorObject)
+GDALMAJOROBJECT_DECL_ACCESSOR(GDALMajorObject)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRCurve.cpp b/csrc/HGDALOGRCurve.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRCurve.cpp
@@ -0,0 +1,26 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRPointIterator.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRCurve.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+OGRGEOMETRY_DEF_VIRT(OGRCurve)
+DELETABLE_DEF_VIRT(OGRCurve)
+OGRCURVE_DEF_VIRT(OGRCurve)
+OGRCURVE_DEF_NONVIRT(OGRCurve)
+OGRCURVE_DEF_ACCESSOR(OGRCurve)
+
diff --git a/csrc/HGDALOGRCurve.h b/csrc/HGDALOGRCurve.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRCurve.h
@@ -0,0 +1,56 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRCURVE_DECL_VIRT(Type) \
+int Type##_getNumPoints ( Type##_p p );\
+OGRPointIterator_p Type##_getPointIterator ( Type##_p p );
+
+
+#define OGRCURVE_DECL_NONVIRT(Type) \
+
+
+
+#define OGRCURVE_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRCURVE_DEF_VIRT(Type) \
+int Type##_getNumPoints ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, getNumPoints, OGRCurve))(p))->getNumPoints();\
+}\
+\
+OGRPointIterator_p Type##_getPointIterator ( Type##_p p ) {\
+return from_nonconst_to_nonconst<OGRPointIterator_t, OGRPointIterator>((OGRPointIterator*)((TYPECASTMETHOD(Type, getPointIterator, OGRCurve))(p))->getPointIterator());\
+}
+
+
+#define OGRCURVE_DEF_NONVIRT(Type) \
+
+
+
+#define OGRCURVE_DEF_ACCESSOR(Type) \
+
+
+
+OGRGEOMETRY_DECL_VIRT(OGRCurve)
+DELETABLE_DECL_VIRT(OGRCurve)
+OGRCURVE_DECL_VIRT(OGRCurve)
+OGRCURVE_DECL_NONVIRT(OGRCurve)
+OGRCURVE_DECL_ACCESSOR(OGRCurve)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRCurvePolygon.cpp b/csrc/HGDALOGRCurvePolygon.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRCurvePolygon.cpp
@@ -0,0 +1,25 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRSurface.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRCurvePolygon.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+OGRSURFACE_DEF_VIRT(OGRCurvePolygon)
+OGRGEOMETRY_DEF_VIRT(OGRCurvePolygon)
+DELETABLE_DEF_VIRT(OGRCurvePolygon)
+OGRCURVEPOLYGON_DEF_VIRT(OGRCurvePolygon)
+OGRCURVEPOLYGON_DEF_NONVIRT(OGRCurvePolygon)
+OGRCURVEPOLYGON_DEF_ACCESSOR(OGRCurvePolygon)
+
diff --git a/csrc/HGDALOGRCurvePolygon.h b/csrc/HGDALOGRCurvePolygon.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRCurvePolygon.h
@@ -0,0 +1,52 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALOGRSurface.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRCURVEPOLYGON_DECL_VIRT(Type) \
+
+
+
+#define OGRCURVEPOLYGON_DECL_NONVIRT(Type) \
+
+
+
+#define OGRCURVEPOLYGON_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRCURVEPOLYGON_DEF_VIRT(Type) \
+
+
+
+#define OGRCURVEPOLYGON_DEF_NONVIRT(Type) \
+
+
+
+#define OGRCURVEPOLYGON_DEF_ACCESSOR(Type) \
+
+
+
+OGRSURFACE_DECL_VIRT(OGRCurvePolygon)
+OGRGEOMETRY_DECL_VIRT(OGRCurvePolygon)
+DELETABLE_DECL_VIRT(OGRCurvePolygon)
+OGRCURVEPOLYGON_DECL_VIRT(OGRCurvePolygon)
+OGRCURVEPOLYGON_DECL_NONVIRT(OGRCurvePolygon)
+OGRCURVEPOLYGON_DECL_ACCESSOR(OGRCurvePolygon)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGREnvelope.cpp b/csrc/HGDALOGREnvelope.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGREnvelope.cpp
@@ -0,0 +1,23 @@
+
+#include "MacroPatternMatch.h"
+
+#include "STDDeletable.h"
+
+#include "ogr_core.h"
+
+#include "HGDALOGREnvelope.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+DELETABLE_DEF_VIRT(OGREnvelope)
+OGRENVELOPE_DEF_VIRT(OGREnvelope)
+OGRENVELOPE_DEF_NONVIRT(OGREnvelope)
+OGRENVELOPE_DEF_ACCESSOR(OGREnvelope)
+
diff --git a/csrc/HGDALOGREnvelope.h b/csrc/HGDALOGREnvelope.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGREnvelope.h
@@ -0,0 +1,80 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "STDDeletable.h"
+
+#include "stdcxxType.h"
+
+
+#define OGRENVELOPE_DECL_VIRT(Type) \
+
+
+
+#define OGRENVELOPE_DECL_NONVIRT(Type) \
+Type##_p Type##_newOGREnvelope (  );
+
+
+#define OGRENVELOPE_DECL_ACCESSOR(Type) \
+double Type##_MinX_get ( Type##_p p );\
+void Type##_MinX_set ( Type##_p p, double x );\
+double Type##_MaxX_get ( Type##_p p );\
+void Type##_MaxX_set ( Type##_p p, double x );\
+double Type##_MinY_get ( Type##_p p );\
+void Type##_MinY_set ( Type##_p p, double x );\
+double Type##_MaxY_get ( Type##_p p );\
+void Type##_MaxY_set ( Type##_p p, double x );
+
+
+#define OGRENVELOPE_DEF_VIRT(Type) \
+
+
+
+#define OGRENVELOPE_DEF_NONVIRT(Type) \
+Type##_p Type##_newOGREnvelope (  ) {\
+Type* newp=new Type();return from_nonconst_to_nonconst<Type##_t, Type>(newp);\
+}
+
+
+#define OGRENVELOPE_DEF_ACCESSOR(Type) \
+double Type##_MinX_get ( Type##_p p ) {\
+return (from_nonconst_to_nonconst<Type, Type##_t>(p))->MinX;\
+}\
+void Type##_MinX_set ( Type##_p p, double x ) {\
+((from_nonconst_to_nonconst<Type, Type##_t>(p))->MinX)=x;\
+}\
+double Type##_MaxX_get ( Type##_p p ) {\
+return (from_nonconst_to_nonconst<Type, Type##_t>(p))->MaxX;\
+}\
+void Type##_MaxX_set ( Type##_p p, double x ) {\
+((from_nonconst_to_nonconst<Type, Type##_t>(p))->MaxX)=x;\
+}\
+double Type##_MinY_get ( Type##_p p ) {\
+return (from_nonconst_to_nonconst<Type, Type##_t>(p))->MinY;\
+}\
+void Type##_MinY_set ( Type##_p p, double x ) {\
+((from_nonconst_to_nonconst<Type, Type##_t>(p))->MinY)=x;\
+}\
+double Type##_MaxY_get ( Type##_p p ) {\
+return (from_nonconst_to_nonconst<Type, Type##_t>(p))->MaxY;\
+}\
+void Type##_MaxY_set ( Type##_p p, double x ) {\
+((from_nonconst_to_nonconst<Type, Type##_t>(p))->MaxY)=x;\
+}
+
+
+DELETABLE_DECL_VIRT(OGREnvelope)
+OGRENVELOPE_DECL_VIRT(OGREnvelope)
+OGRENVELOPE_DECL_NONVIRT(OGREnvelope)
+OGRENVELOPE_DECL_ACCESSOR(OGREnvelope)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRFeature.cpp b/csrc/HGDALOGRFeature.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRFeature.cpp
@@ -0,0 +1,25 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+#include "ogr_feature.h"
+
+#include "HGDALOGRFeature.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+DELETABLE_DEF_VIRT(OGRFeature)
+OGRFEATURE_DEF_VIRT(OGRFeature)
+OGRFEATURE_DEF_NONVIRT(OGRFeature)
+OGRFEATURE_DEF_ACCESSOR(OGRFeature)
+
diff --git a/csrc/HGDALOGRFeature.h b/csrc/HGDALOGRFeature.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRFeature.h
@@ -0,0 +1,75 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "STDDeletable.h"
+
+#include "stdcxxType.h"
+
+
+#define OGRFEATURE_DECL_VIRT(Type) \
+
+
+
+#define OGRFEATURE_DECL_NONVIRT(Type) \
+int Type##_oGRFeature_GetFID ( Type##_p p );\
+int Type##_oGRFeature_GetFieldCount ( Type##_p p );\
+int Type##_oGRFeature_GetFieldAsInteger ( Type##_p p, int i );\
+int Type##_oGRFeature_GetFieldAsInteger64 ( Type##_p p, int i );\
+const char* Type##_oGRFeature_GetFieldAsString ( Type##_p p, int i );\
+OGRGeometry_p Type##_oGRFeature_GetGeometryRef ( Type##_p p );
+
+
+#define OGRFEATURE_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRFEATURE_DEF_VIRT(Type) \
+
+
+
+#define OGRFEATURE_DEF_NONVIRT(Type) \
+int Type##_oGRFeature_GetFID ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, oGRFeature_GetFID, OGRFeature))(p))->GetFID();\
+}\
+\
+int Type##_oGRFeature_GetFieldCount ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, oGRFeature_GetFieldCount, OGRFeature))(p))->GetFieldCount();\
+}\
+\
+int Type##_oGRFeature_GetFieldAsInteger ( Type##_p p, int i ) {\
+return ((TYPECASTMETHOD(Type, oGRFeature_GetFieldAsInteger, OGRFeature))(p))->GetFieldAsInteger(i);\
+}\
+\
+int Type##_oGRFeature_GetFieldAsInteger64 ( Type##_p p, int i ) {\
+return ((TYPECASTMETHOD(Type, oGRFeature_GetFieldAsInteger64, OGRFeature))(p))->GetFieldAsInteger64(i);\
+}\
+\
+const char* Type##_oGRFeature_GetFieldAsString ( Type##_p p, int i ) {\
+return ((TYPECASTMETHOD(Type, oGRFeature_GetFieldAsString, OGRFeature))(p))->GetFieldAsString(i);\
+}\
+\
+OGRGeometry_p Type##_oGRFeature_GetGeometryRef ( Type##_p p ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, oGRFeature_GetGeometryRef, OGRFeature))(p))->GetGeometryRef());\
+}
+
+
+#define OGRFEATURE_DEF_ACCESSOR(Type) \
+
+
+
+DELETABLE_DECL_VIRT(OGRFeature)
+OGRFEATURE_DECL_VIRT(OGRFeature)
+OGRFEATURE_DECL_NONVIRT(OGRFeature)
+OGRFEATURE_DECL_ACCESSOR(OGRFeature)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRFeatureDefn.cpp b/csrc/HGDALOGRFeatureDefn.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRFeatureDefn.cpp
@@ -0,0 +1,25 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRFieldDefn.h"
+
+#include "STDDeletable.h"
+
+#include "ogr_feature.h"
+
+#include "HGDALOGRFeatureDefn.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+DELETABLE_DEF_VIRT(OGRFeatureDefn)
+OGRFEATUREDEFN_DEF_VIRT(OGRFeatureDefn)
+OGRFEATUREDEFN_DEF_NONVIRT(OGRFeatureDefn)
+OGRFEATUREDEFN_DEF_ACCESSOR(OGRFeatureDefn)
+
diff --git a/csrc/HGDALOGRFeatureDefn.h b/csrc/HGDALOGRFeatureDefn.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRFeatureDefn.h
@@ -0,0 +1,60 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "STDDeletable.h"
+
+#include "stdcxxType.h"
+
+
+#define OGRFEATUREDEFN_DECL_VIRT(Type) \
+int Type##_GetFieldCount ( Type##_p p );\
+OGRFieldDefn_p Type##_GetFieldDefn ( Type##_p p, int i );\
+int Type##_GetGeomFieldCount ( Type##_p p );
+
+
+#define OGRFEATUREDEFN_DECL_NONVIRT(Type) \
+
+
+
+#define OGRFEATUREDEFN_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRFEATUREDEFN_DEF_VIRT(Type) \
+int Type##_GetFieldCount ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, GetFieldCount, OGRFeatureDefn))(p))->GetFieldCount();\
+}\
+\
+OGRFieldDefn_p Type##_GetFieldDefn ( Type##_p p, int i ) {\
+return from_nonconst_to_nonconst<OGRFieldDefn_t, OGRFieldDefn>((OGRFieldDefn*)((TYPECASTMETHOD(Type, GetFieldDefn, OGRFeatureDefn))(p))->GetFieldDefn(i));\
+}\
+\
+int Type##_GetGeomFieldCount ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, GetGeomFieldCount, OGRFeatureDefn))(p))->GetGeomFieldCount();\
+}
+
+
+#define OGRFEATUREDEFN_DEF_NONVIRT(Type) \
+
+
+
+#define OGRFEATUREDEFN_DEF_ACCESSOR(Type) \
+
+
+
+DELETABLE_DECL_VIRT(OGRFeatureDefn)
+OGRFEATUREDEFN_DECL_VIRT(OGRFeatureDefn)
+OGRFEATUREDEFN_DECL_NONVIRT(OGRFeatureDefn)
+OGRFEATUREDEFN_DECL_ACCESSOR(OGRFeatureDefn)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRFieldDefn.cpp b/csrc/HGDALOGRFieldDefn.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRFieldDefn.cpp
@@ -0,0 +1,23 @@
+
+#include "MacroPatternMatch.h"
+
+#include "STDDeletable.h"
+
+#include "ogr_feature.h"
+
+#include "HGDALOGRFieldDefn.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+DELETABLE_DEF_VIRT(OGRFieldDefn)
+OGRFIELDDEFN_DEF_VIRT(OGRFieldDefn)
+OGRFIELDDEFN_DEF_NONVIRT(OGRFieldDefn)
+OGRFIELDDEFN_DEF_ACCESSOR(OGRFieldDefn)
+
diff --git a/csrc/HGDALOGRFieldDefn.h b/csrc/HGDALOGRFieldDefn.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRFieldDefn.h
@@ -0,0 +1,55 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "STDDeletable.h"
+
+#include "stdcxxType.h"
+
+
+#define OGRFIELDDEFN_DECL_VIRT(Type) \
+
+
+
+#define OGRFIELDDEFN_DECL_NONVIRT(Type) \
+const char* Type##_oGRFieldDefn_GetNameRef ( Type##_p p );\
+unsigned int Type##_oGRFieldDefn_GetType ( Type##_p p );
+
+
+#define OGRFIELDDEFN_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRFIELDDEFN_DEF_VIRT(Type) \
+
+
+
+#define OGRFIELDDEFN_DEF_NONVIRT(Type) \
+const char* Type##_oGRFieldDefn_GetNameRef ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, oGRFieldDefn_GetNameRef, OGRFieldDefn))(p))->GetNameRef();\
+}\
+\
+unsigned int Type##_oGRFieldDefn_GetType ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, oGRFieldDefn_GetType, OGRFieldDefn))(p))->GetType();\
+}
+
+
+#define OGRFIELDDEFN_DEF_ACCESSOR(Type) \
+
+
+
+DELETABLE_DECL_VIRT(OGRFieldDefn)
+OGRFIELDDEFN_DECL_VIRT(OGRFieldDefn)
+OGRFIELDDEFN_DECL_NONVIRT(OGRFieldDefn)
+OGRFIELDDEFN_DECL_ACCESSOR(OGRFieldDefn)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRGeometry.cpp b/csrc/HGDALOGRGeometry.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRGeometry.cpp
@@ -0,0 +1,31 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRPolygon.h"
+
+#include "HGDALOGRMultiPolygon.h"
+
+#include "HGDALOGREnvelope.h"
+
+#include "HGDALOGRPoint.h"
+
+#include "STDDeletable.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRGeometry.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+DELETABLE_DEF_VIRT(OGRGeometry)
+OGRGEOMETRY_DEF_VIRT(OGRGeometry)
+OGRGEOMETRY_DEF_NONVIRT(OGRGeometry)
+OGRGEOMETRY_DEF_ACCESSOR(OGRGeometry)
+
diff --git a/csrc/HGDALOGRGeometry.h b/csrc/HGDALOGRGeometry.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRGeometry.h
@@ -0,0 +1,177 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "STDDeletable.h"
+
+#include "stdcxxType.h"
+
+
+#define OGRGEOMETRY_DECL_VIRT(Type) \
+unsigned int Type##_getGeometryType ( Type##_p p );\
+void Type##_getEnvelope ( Type##_p p, OGREnvelope_p psEnvelope );\
+bool Type##_Intersects ( Type##_p p, OGRGeometry_p g );\
+bool Type##_Equals ( Type##_p p, OGRGeometry_p g );\
+bool Type##_Disjoint ( Type##_p p, OGRGeometry_p g );\
+bool Type##_Touches ( Type##_p p, OGRGeometry_p g );\
+bool Type##_Crosses ( Type##_p p, OGRGeometry_p g );\
+bool Type##_Within ( Type##_p p, OGRGeometry_p g );\
+bool Type##_Contains ( Type##_p p, OGRGeometry_p g );\
+bool Type##_Overlaps ( Type##_p p, OGRGeometry_p g );\
+OGRGeometry_p Type##_Boundary ( Type##_p p );\
+double Type##_Distance ( Type##_p p, OGRGeometry_p poOtherGeom );\
+OGRGeometry_p Type##_ConvexHull ( Type##_p p );\
+OGRGeometry_p Type##_Buffer ( Type##_p p, double dfDist, int nQuadSegs );\
+OGRGeometry_p Type##_Intersection ( Type##_p p, OGRGeometry_p poOtherGeom );\
+OGRGeometry_p Type##_Union ( Type##_p p, OGRGeometry_p poOtherGeom );\
+OGRGeometry_p Type##_UnionCascaded ( Type##_p p );\
+OGRGeometry_p Type##_Difference ( Type##_p p, OGRGeometry_p poOtherGeom );\
+OGRGeometry_p Type##_SymDifference ( Type##_p p, OGRGeometry_p poOtherGeom );\
+int Type##_Centroid ( Type##_p p, OGRPoint_p poPoint );\
+OGRGeometry_p Type##_Simplify ( Type##_p p, double dTolerance );\
+OGRGeometry_p Type##_DelaunayTriangulation ( Type##_p p, double dfTolerance, int bOnlyEdges );\
+OGRGeometry_p Type##_Polygonize ( Type##_p p );\
+double Type##_Distance3D ( Type##_p p, OGRGeometry_p poOtherGeom );
+
+
+#define OGRGEOMETRY_DECL_NONVIRT(Type) \
+OGRGeometry_p Type##_oGRGeometry_SimplifyPreserveTopology ( Type##_p p, double dTolerance );\
+OGRPolygon_p Type##_oGRGeometry_toPolygon ( Type##_p p );\
+OGRMultiPolygon_p Type##_oGRGeometry_toMultiPolygon ( Type##_p p );
+
+
+#define OGRGEOMETRY_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRGEOMETRY_DEF_VIRT(Type) \
+unsigned int Type##_getGeometryType ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, getGeometryType, OGRGeometry))(p))->getGeometryType();\
+}\
+\
+void Type##_getEnvelope ( Type##_p p, OGREnvelope_p psEnvelope ) {\
+((TYPECASTMETHOD(Type, getEnvelope, OGRGeometry))(p))->getEnvelope(from_nonconst_to_nonconst<OGREnvelope, OGREnvelope_t>(psEnvelope));\
+}\
+\
+bool Type##_Intersects ( Type##_p p, OGRGeometry_p g ) {\
+return ((TYPECASTMETHOD(Type, Intersects, OGRGeometry))(p))->Intersects(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(g));\
+}\
+\
+bool Type##_Equals ( Type##_p p, OGRGeometry_p g ) {\
+return ((TYPECASTMETHOD(Type, Equals, OGRGeometry))(p))->Equals(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(g));\
+}\
+\
+bool Type##_Disjoint ( Type##_p p, OGRGeometry_p g ) {\
+return ((TYPECASTMETHOD(Type, Disjoint, OGRGeometry))(p))->Disjoint(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(g));\
+}\
+\
+bool Type##_Touches ( Type##_p p, OGRGeometry_p g ) {\
+return ((TYPECASTMETHOD(Type, Touches, OGRGeometry))(p))->Touches(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(g));\
+}\
+\
+bool Type##_Crosses ( Type##_p p, OGRGeometry_p g ) {\
+return ((TYPECASTMETHOD(Type, Crosses, OGRGeometry))(p))->Crosses(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(g));\
+}\
+\
+bool Type##_Within ( Type##_p p, OGRGeometry_p g ) {\
+return ((TYPECASTMETHOD(Type, Within, OGRGeometry))(p))->Within(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(g));\
+}\
+\
+bool Type##_Contains ( Type##_p p, OGRGeometry_p g ) {\
+return ((TYPECASTMETHOD(Type, Contains, OGRGeometry))(p))->Contains(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(g));\
+}\
+\
+bool Type##_Overlaps ( Type##_p p, OGRGeometry_p g ) {\
+return ((TYPECASTMETHOD(Type, Overlaps, OGRGeometry))(p))->Overlaps(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(g));\
+}\
+\
+OGRGeometry_p Type##_Boundary ( Type##_p p ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, Boundary, OGRGeometry))(p))->Boundary());\
+}\
+\
+double Type##_Distance ( Type##_p p, OGRGeometry_p poOtherGeom ) {\
+return ((TYPECASTMETHOD(Type, Distance, OGRGeometry))(p))->Distance(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(poOtherGeom));\
+}\
+\
+OGRGeometry_p Type##_ConvexHull ( Type##_p p ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, ConvexHull, OGRGeometry))(p))->ConvexHull());\
+}\
+\
+OGRGeometry_p Type##_Buffer ( Type##_p p, double dfDist, int nQuadSegs ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, Buffer, OGRGeometry))(p))->Buffer(dfDist, nQuadSegs));\
+}\
+\
+OGRGeometry_p Type##_Intersection ( Type##_p p, OGRGeometry_p poOtherGeom ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, Intersection, OGRGeometry))(p))->Intersection(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(poOtherGeom)));\
+}\
+\
+OGRGeometry_p Type##_Union ( Type##_p p, OGRGeometry_p poOtherGeom ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, Union, OGRGeometry))(p))->Union(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(poOtherGeom)));\
+}\
+\
+OGRGeometry_p Type##_UnionCascaded ( Type##_p p ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, UnionCascaded, OGRGeometry))(p))->UnionCascaded());\
+}\
+\
+OGRGeometry_p Type##_Difference ( Type##_p p, OGRGeometry_p poOtherGeom ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, Difference, OGRGeometry))(p))->Difference(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(poOtherGeom)));\
+}\
+\
+OGRGeometry_p Type##_SymDifference ( Type##_p p, OGRGeometry_p poOtherGeom ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, SymDifference, OGRGeometry))(p))->SymDifference(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(poOtherGeom)));\
+}\
+\
+int Type##_Centroid ( Type##_p p, OGRPoint_p poPoint ) {\
+return ((TYPECASTMETHOD(Type, Centroid, OGRGeometry))(p))->Centroid(from_nonconst_to_nonconst<OGRPoint, OGRPoint_t>(poPoint));\
+}\
+\
+OGRGeometry_p Type##_Simplify ( Type##_p p, double dTolerance ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, Simplify, OGRGeometry))(p))->Simplify(dTolerance));\
+}\
+\
+OGRGeometry_p Type##_DelaunayTriangulation ( Type##_p p, double dfTolerance, int bOnlyEdges ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, DelaunayTriangulation, OGRGeometry))(p))->DelaunayTriangulation(dfTolerance, bOnlyEdges));\
+}\
+\
+OGRGeometry_p Type##_Polygonize ( Type##_p p ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, Polygonize, OGRGeometry))(p))->Polygonize());\
+}\
+\
+double Type##_Distance3D ( Type##_p p, OGRGeometry_p poOtherGeom ) {\
+return ((TYPECASTMETHOD(Type, Distance3D, OGRGeometry))(p))->Distance3D(from_nonconst_to_nonconst<OGRGeometry, OGRGeometry_t>(poOtherGeom));\
+}
+
+
+#define OGRGEOMETRY_DEF_NONVIRT(Type) \
+OGRGeometry_p Type##_oGRGeometry_SimplifyPreserveTopology ( Type##_p p, double dTolerance ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, oGRGeometry_SimplifyPreserveTopology, OGRGeometry))(p))->SimplifyPreserveTopology(dTolerance));\
+}\
+\
+OGRPolygon_p Type##_oGRGeometry_toPolygon ( Type##_p p ) {\
+return from_nonconst_to_nonconst<OGRPolygon_t, OGRPolygon>((OGRPolygon*)((TYPECASTMETHOD(Type, oGRGeometry_toPolygon, OGRGeometry))(p))->toPolygon());\
+}\
+\
+OGRMultiPolygon_p Type##_oGRGeometry_toMultiPolygon ( Type##_p p ) {\
+return from_nonconst_to_nonconst<OGRMultiPolygon_t, OGRMultiPolygon>((OGRMultiPolygon*)((TYPECASTMETHOD(Type, oGRGeometry_toMultiPolygon, OGRGeometry))(p))->toMultiPolygon());\
+}
+
+
+#define OGRGEOMETRY_DEF_ACCESSOR(Type) \
+
+
+
+DELETABLE_DECL_VIRT(OGRGeometry)
+OGRGEOMETRY_DECL_VIRT(OGRGeometry)
+OGRGEOMETRY_DECL_NONVIRT(OGRGeometry)
+OGRGEOMETRY_DECL_ACCESSOR(OGRGeometry)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRGeometryCollection.cpp b/csrc/HGDALOGRGeometryCollection.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRGeometryCollection.cpp
@@ -0,0 +1,24 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRGeometryCollection.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+OGRGEOMETRY_DEF_VIRT(OGRGeometryCollection)
+DELETABLE_DEF_VIRT(OGRGeometryCollection)
+OGRGEOMETRYCOLLECTION_DEF_VIRT(OGRGeometryCollection)
+OGRGEOMETRYCOLLECTION_DEF_NONVIRT(OGRGeometryCollection)
+OGRGEOMETRYCOLLECTION_DEF_ACCESSOR(OGRGeometryCollection)
+
diff --git a/csrc/HGDALOGRGeometryCollection.h b/csrc/HGDALOGRGeometryCollection.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRGeometryCollection.h
@@ -0,0 +1,56 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRGEOMETRYCOLLECTION_DECL_VIRT(Type) \
+
+
+
+#define OGRGEOMETRYCOLLECTION_DECL_NONVIRT(Type) \
+int Type##_oGRGeometryCollection_getNumGeometries ( Type##_p p );\
+OGRGeometry_p Type##_oGRGeometryCollection_getGeometryRef ( Type##_p p, int i );
+
+
+#define OGRGEOMETRYCOLLECTION_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRGEOMETRYCOLLECTION_DEF_VIRT(Type) \
+
+
+
+#define OGRGEOMETRYCOLLECTION_DEF_NONVIRT(Type) \
+int Type##_oGRGeometryCollection_getNumGeometries ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, oGRGeometryCollection_getNumGeometries, OGRGeometryCollection))(p))->getNumGeometries();\
+}\
+\
+OGRGeometry_p Type##_oGRGeometryCollection_getGeometryRef ( Type##_p p, int i ) {\
+return from_nonconst_to_nonconst<OGRGeometry_t, OGRGeometry>((OGRGeometry*)((TYPECASTMETHOD(Type, oGRGeometryCollection_getGeometryRef, OGRGeometryCollection))(p))->getGeometryRef(i));\
+}
+
+
+#define OGRGEOMETRYCOLLECTION_DEF_ACCESSOR(Type) \
+
+
+
+OGRGEOMETRY_DECL_VIRT(OGRGeometryCollection)
+DELETABLE_DECL_VIRT(OGRGeometryCollection)
+OGRGEOMETRYCOLLECTION_DECL_VIRT(OGRGeometryCollection)
+OGRGEOMETRYCOLLECTION_DECL_NONVIRT(OGRGeometryCollection)
+OGRGEOMETRYCOLLECTION_DECL_ACCESSOR(OGRGeometryCollection)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRLayer.cpp b/csrc/HGDALOGRLayer.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRLayer.cpp
@@ -0,0 +1,28 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRFeature.h"
+
+#include "HGDALOGRFeatureDefn.h"
+
+#include "HGDALGDALMajorObject.h"
+
+#include "ogrsf_frmts.h"
+
+#include "HGDALOGRLayer.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+GDALMAJOROBJECT_DEF_VIRT(OGRLayer)
+DELETABLE_DEF_VIRT(OGRLayer)
+OGRLAYER_DEF_VIRT(OGRLayer)
+OGRLAYER_DEF_NONVIRT(OGRLayer)
+OGRLAYER_DEF_ACCESSOR(OGRLayer)
+
diff --git a/csrc/HGDALOGRLayer.h b/csrc/HGDALOGRLayer.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRLayer.h
@@ -0,0 +1,71 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALGDALMajorObject.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRLAYER_DECL_VIRT(Type) \
+OGRFeature_p Type##_GetFeature ( Type##_p p, int nFID );\
+int Type##_GetFeatureCount ( Type##_p p, int bForce );\
+OGRFeatureDefn_p Type##_GetLayerDefn ( Type##_p p );\
+OGRFeature_p Type##_GetNextFeature ( Type##_p p );\
+void Type##_ResetReading ( Type##_p p );
+
+
+#define OGRLAYER_DECL_NONVIRT(Type) \
+
+
+
+#define OGRLAYER_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRLAYER_DEF_VIRT(Type) \
+OGRFeature_p Type##_GetFeature ( Type##_p p, int nFID ) {\
+return from_nonconst_to_nonconst<OGRFeature_t, OGRFeature>((OGRFeature*)((TYPECASTMETHOD(Type, GetFeature, OGRLayer))(p))->GetFeature(nFID));\
+}\
+\
+int Type##_GetFeatureCount ( Type##_p p, int bForce ) {\
+return ((TYPECASTMETHOD(Type, GetFeatureCount, OGRLayer))(p))->GetFeatureCount(bForce);\
+}\
+\
+OGRFeatureDefn_p Type##_GetLayerDefn ( Type##_p p ) {\
+return from_nonconst_to_nonconst<OGRFeatureDefn_t, OGRFeatureDefn>((OGRFeatureDefn*)((TYPECASTMETHOD(Type, GetLayerDefn, OGRLayer))(p))->GetLayerDefn());\
+}\
+\
+OGRFeature_p Type##_GetNextFeature ( Type##_p p ) {\
+return from_nonconst_to_nonconst<OGRFeature_t, OGRFeature>((OGRFeature*)((TYPECASTMETHOD(Type, GetNextFeature, OGRLayer))(p))->GetNextFeature());\
+}\
+\
+void Type##_ResetReading ( Type##_p p ) {\
+((TYPECASTMETHOD(Type, ResetReading, OGRLayer))(p))->ResetReading();\
+}
+
+
+#define OGRLAYER_DEF_NONVIRT(Type) \
+
+
+
+#define OGRLAYER_DEF_ACCESSOR(Type) \
+
+
+
+GDALMAJOROBJECT_DECL_VIRT(OGRLayer)
+DELETABLE_DECL_VIRT(OGRLayer)
+OGRLAYER_DECL_VIRT(OGRLayer)
+OGRLAYER_DECL_NONVIRT(OGRLayer)
+OGRLAYER_DECL_ACCESSOR(OGRLayer)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRLineString.cpp b/csrc/HGDALOGRLineString.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRLineString.cpp
@@ -0,0 +1,26 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRSimpleCurve.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRLineString.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+OGRSIMPLECURVE_DEF_VIRT(OGRLineString)
+OGRCURVE_DEF_VIRT(OGRLineString)
+OGRGEOMETRY_DEF_VIRT(OGRLineString)
+DELETABLE_DEF_VIRT(OGRLineString)
+OGRLINESTRING_DEF_VIRT(OGRLineString)
+OGRLINESTRING_DEF_NONVIRT(OGRLineString)
+OGRLINESTRING_DEF_ACCESSOR(OGRLineString)
+
diff --git a/csrc/HGDALOGRLineString.h b/csrc/HGDALOGRLineString.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRLineString.h
@@ -0,0 +1,55 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALOGRSimpleCurve.h"
+
+#include "HGDALOGRCurve.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRLINESTRING_DECL_VIRT(Type) \
+
+
+
+#define OGRLINESTRING_DECL_NONVIRT(Type) \
+
+
+
+#define OGRLINESTRING_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRLINESTRING_DEF_VIRT(Type) \
+
+
+
+#define OGRLINESTRING_DEF_NONVIRT(Type) \
+
+
+
+#define OGRLINESTRING_DEF_ACCESSOR(Type) \
+
+
+
+OGRSIMPLECURVE_DECL_VIRT(OGRLineString)
+OGRCURVE_DECL_VIRT(OGRLineString)
+OGRGEOMETRY_DECL_VIRT(OGRLineString)
+DELETABLE_DECL_VIRT(OGRLineString)
+OGRLINESTRING_DECL_VIRT(OGRLineString)
+OGRLINESTRING_DECL_NONVIRT(OGRLineString)
+OGRLINESTRING_DECL_ACCESSOR(OGRLineString)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRLinearRing.cpp b/csrc/HGDALOGRLinearRing.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRLinearRing.cpp
@@ -0,0 +1,27 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRLineString.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRLinearRing.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+OGRLINESTRING_DEF_VIRT(OGRLinearRing)
+OGRSIMPLECURVE_DEF_VIRT(OGRLinearRing)
+OGRCURVE_DEF_VIRT(OGRLinearRing)
+OGRGEOMETRY_DEF_VIRT(OGRLinearRing)
+DELETABLE_DEF_VIRT(OGRLinearRing)
+OGRLINEARRING_DEF_VIRT(OGRLinearRing)
+OGRLINEARRING_DEF_NONVIRT(OGRLinearRing)
+OGRLINEARRING_DEF_ACCESSOR(OGRLinearRing)
+
diff --git a/csrc/HGDALOGRLinearRing.h b/csrc/HGDALOGRLinearRing.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRLinearRing.h
@@ -0,0 +1,58 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALOGRLineString.h"
+
+#include "HGDALOGRSimpleCurve.h"
+
+#include "HGDALOGRCurve.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRLINEARRING_DECL_VIRT(Type) \
+
+
+
+#define OGRLINEARRING_DECL_NONVIRT(Type) \
+
+
+
+#define OGRLINEARRING_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRLINEARRING_DEF_VIRT(Type) \
+
+
+
+#define OGRLINEARRING_DEF_NONVIRT(Type) \
+
+
+
+#define OGRLINEARRING_DEF_ACCESSOR(Type) \
+
+
+
+OGRLINESTRING_DECL_VIRT(OGRLinearRing)
+OGRSIMPLECURVE_DECL_VIRT(OGRLinearRing)
+OGRCURVE_DECL_VIRT(OGRLinearRing)
+OGRGEOMETRY_DECL_VIRT(OGRLinearRing)
+DELETABLE_DECL_VIRT(OGRLinearRing)
+OGRLINEARRING_DECL_VIRT(OGRLinearRing)
+OGRLINEARRING_DECL_NONVIRT(OGRLinearRing)
+OGRLINEARRING_DECL_ACCESSOR(OGRLinearRing)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRMultiPolygon.cpp b/csrc/HGDALOGRMultiPolygon.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRMultiPolygon.cpp
@@ -0,0 +1,26 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRMultiSurface.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRMultiPolygon.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+OGRMULTISURFACE_DEF_VIRT(OGRMultiPolygon)
+OGRGEOMETRYCOLLECTION_DEF_VIRT(OGRMultiPolygon)
+OGRGEOMETRY_DEF_VIRT(OGRMultiPolygon)
+DELETABLE_DEF_VIRT(OGRMultiPolygon)
+OGRMULTIPOLYGON_DEF_VIRT(OGRMultiPolygon)
+OGRMULTIPOLYGON_DEF_NONVIRT(OGRMultiPolygon)
+OGRMULTIPOLYGON_DEF_ACCESSOR(OGRMultiPolygon)
+
diff --git a/csrc/HGDALOGRMultiPolygon.h b/csrc/HGDALOGRMultiPolygon.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRMultiPolygon.h
@@ -0,0 +1,55 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALOGRMultiSurface.h"
+
+#include "HGDALOGRGeometryCollection.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRMULTIPOLYGON_DECL_VIRT(Type) \
+
+
+
+#define OGRMULTIPOLYGON_DECL_NONVIRT(Type) \
+
+
+
+#define OGRMULTIPOLYGON_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRMULTIPOLYGON_DEF_VIRT(Type) \
+
+
+
+#define OGRMULTIPOLYGON_DEF_NONVIRT(Type) \
+
+
+
+#define OGRMULTIPOLYGON_DEF_ACCESSOR(Type) \
+
+
+
+OGRMULTISURFACE_DECL_VIRT(OGRMultiPolygon)
+OGRGEOMETRYCOLLECTION_DECL_VIRT(OGRMultiPolygon)
+OGRGEOMETRY_DECL_VIRT(OGRMultiPolygon)
+DELETABLE_DECL_VIRT(OGRMultiPolygon)
+OGRMULTIPOLYGON_DECL_VIRT(OGRMultiPolygon)
+OGRMULTIPOLYGON_DECL_NONVIRT(OGRMultiPolygon)
+OGRMULTIPOLYGON_DECL_ACCESSOR(OGRMultiPolygon)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRMultiSurface.cpp b/csrc/HGDALOGRMultiSurface.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRMultiSurface.cpp
@@ -0,0 +1,25 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRGeometryCollection.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRMultiSurface.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+OGRGEOMETRYCOLLECTION_DEF_VIRT(OGRMultiSurface)
+OGRGEOMETRY_DEF_VIRT(OGRMultiSurface)
+DELETABLE_DEF_VIRT(OGRMultiSurface)
+OGRMULTISURFACE_DEF_VIRT(OGRMultiSurface)
+OGRMULTISURFACE_DEF_NONVIRT(OGRMultiSurface)
+OGRMULTISURFACE_DEF_ACCESSOR(OGRMultiSurface)
+
diff --git a/csrc/HGDALOGRMultiSurface.h b/csrc/HGDALOGRMultiSurface.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRMultiSurface.h
@@ -0,0 +1,52 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALOGRGeometryCollection.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRMULTISURFACE_DECL_VIRT(Type) \
+
+
+
+#define OGRMULTISURFACE_DECL_NONVIRT(Type) \
+
+
+
+#define OGRMULTISURFACE_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRMULTISURFACE_DEF_VIRT(Type) \
+
+
+
+#define OGRMULTISURFACE_DEF_NONVIRT(Type) \
+
+
+
+#define OGRMULTISURFACE_DEF_ACCESSOR(Type) \
+
+
+
+OGRGEOMETRYCOLLECTION_DECL_VIRT(OGRMultiSurface)
+OGRGEOMETRY_DECL_VIRT(OGRMultiSurface)
+DELETABLE_DECL_VIRT(OGRMultiSurface)
+OGRMULTISURFACE_DECL_VIRT(OGRMultiSurface)
+OGRMULTISURFACE_DECL_NONVIRT(OGRMultiSurface)
+OGRMULTISURFACE_DECL_ACCESSOR(OGRMultiSurface)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRPoint.cpp b/csrc/HGDALOGRPoint.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRPoint.cpp
@@ -0,0 +1,24 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRPoint.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+OGRGEOMETRY_DEF_VIRT(OGRPoint)
+DELETABLE_DEF_VIRT(OGRPoint)
+OGRPOINT_DEF_VIRT(OGRPoint)
+OGRPOINT_DEF_NONVIRT(OGRPoint)
+OGRPOINT_DEF_ACCESSOR(OGRPoint)
+
diff --git a/csrc/HGDALOGRPoint.h b/csrc/HGDALOGRPoint.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRPoint.h
@@ -0,0 +1,106 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRPOINT_DECL_VIRT(Type) \
+
+
+
+#define OGRPOINT_DECL_NONVIRT(Type) \
+Type##_p Type##_newOGRPoint (  );\
+Type##_p Type##_newOGRPoint2 ( double x, double y );\
+Type##_p Type##_newOGRPoint3 ( double x, double y, double z );\
+Type##_p Type##_newOGRPoint4 ( double x, double y, double z, double m );\
+double Type##_oGRPoint_getX ( Type##_p p );\
+double Type##_oGRPoint_getY ( Type##_p p );\
+double Type##_oGRPoint_getZ ( Type##_p p );\
+double Type##_oGRPoint_getM ( Type##_p p );\
+void Type##_oGRPoint_setX ( Type##_p p, double xIn );\
+void Type##_oGRPoint_setY ( Type##_p p, double yIn );\
+void Type##_oGRPoint_setZ ( Type##_p p, double zIn );\
+void Type##_oGRPoint_setM ( Type##_p p, double mIn );
+
+
+#define OGRPOINT_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRPOINT_DEF_VIRT(Type) \
+
+
+
+#define OGRPOINT_DEF_NONVIRT(Type) \
+Type##_p Type##_newOGRPoint (  ) {\
+Type* newp=new Type();return from_nonconst_to_nonconst<Type##_t, Type>(newp);\
+}\
+\
+Type##_p Type##_newOGRPoint2 ( double x, double y ) {\
+Type* newp=new Type(x, y);return from_nonconst_to_nonconst<Type##_t, Type>(newp);\
+}\
+\
+Type##_p Type##_newOGRPoint3 ( double x, double y, double z ) {\
+Type* newp=new Type(x, y, z);return from_nonconst_to_nonconst<Type##_t, Type>(newp);\
+}\
+\
+Type##_p Type##_newOGRPoint4 ( double x, double y, double z, double m ) {\
+Type* newp=new Type(x, y, z, m);return from_nonconst_to_nonconst<Type##_t, Type>(newp);\
+}\
+\
+double Type##_oGRPoint_getX ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, oGRPoint_getX, OGRPoint))(p))->getX();\
+}\
+\
+double Type##_oGRPoint_getY ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, oGRPoint_getY, OGRPoint))(p))->getY();\
+}\
+\
+double Type##_oGRPoint_getZ ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, oGRPoint_getZ, OGRPoint))(p))->getZ();\
+}\
+\
+double Type##_oGRPoint_getM ( Type##_p p ) {\
+return ((TYPECASTMETHOD(Type, oGRPoint_getM, OGRPoint))(p))->getM();\
+}\
+\
+void Type##_oGRPoint_setX ( Type##_p p, double xIn ) {\
+((TYPECASTMETHOD(Type, oGRPoint_setX, OGRPoint))(p))->setX(xIn);\
+}\
+\
+void Type##_oGRPoint_setY ( Type##_p p, double yIn ) {\
+((TYPECASTMETHOD(Type, oGRPoint_setY, OGRPoint))(p))->setY(yIn);\
+}\
+\
+void Type##_oGRPoint_setZ ( Type##_p p, double zIn ) {\
+((TYPECASTMETHOD(Type, oGRPoint_setZ, OGRPoint))(p))->setZ(zIn);\
+}\
+\
+void Type##_oGRPoint_setM ( Type##_p p, double mIn ) {\
+((TYPECASTMETHOD(Type, oGRPoint_setM, OGRPoint))(p))->setM(mIn);\
+}
+
+
+#define OGRPOINT_DEF_ACCESSOR(Type) \
+
+
+
+OGRGEOMETRY_DECL_VIRT(OGRPoint)
+DELETABLE_DECL_VIRT(OGRPoint)
+OGRPOINT_DECL_VIRT(OGRPoint)
+OGRPOINT_DECL_NONVIRT(OGRPoint)
+OGRPOINT_DECL_ACCESSOR(OGRPoint)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRPointIterator.cpp b/csrc/HGDALOGRPointIterator.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRPointIterator.cpp
@@ -0,0 +1,25 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRPoint.h"
+
+#include "STDDeletable.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRPointIterator.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+DELETABLE_DEF_VIRT(OGRPointIterator)
+OGRPOINTITERATOR_DEF_VIRT(OGRPointIterator)
+OGRPOINTITERATOR_DEF_NONVIRT(OGRPointIterator)
+OGRPOINTITERATOR_DEF_ACCESSOR(OGRPointIterator)
+
diff --git a/csrc/HGDALOGRPointIterator.h b/csrc/HGDALOGRPointIterator.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRPointIterator.h
@@ -0,0 +1,50 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "STDDeletable.h"
+
+#include "stdcxxType.h"
+
+
+#define OGRPOINTITERATOR_DECL_VIRT(Type) \
+bool Type##_getNextPoint ( Type##_p p, OGRPoint_p pt );
+
+
+#define OGRPOINTITERATOR_DECL_NONVIRT(Type) \
+
+
+
+#define OGRPOINTITERATOR_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRPOINTITERATOR_DEF_VIRT(Type) \
+bool Type##_getNextPoint ( Type##_p p, OGRPoint_p pt ) {\
+return ((TYPECASTMETHOD(Type, getNextPoint, OGRPointIterator))(p))->getNextPoint(from_nonconst_to_nonconst<OGRPoint, OGRPoint_t>(pt));\
+}
+
+
+#define OGRPOINTITERATOR_DEF_NONVIRT(Type) \
+
+
+
+#define OGRPOINTITERATOR_DEF_ACCESSOR(Type) \
+
+
+
+DELETABLE_DECL_VIRT(OGRPointIterator)
+OGRPOINTITERATOR_DECL_VIRT(OGRPointIterator)
+OGRPOINTITERATOR_DECL_NONVIRT(OGRPointIterator)
+OGRPOINTITERATOR_DECL_ACCESSOR(OGRPointIterator)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRPolygon.cpp b/csrc/HGDALOGRPolygon.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRPolygon.cpp
@@ -0,0 +1,28 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRLinearRing.h"
+
+#include "HGDALOGRCurvePolygon.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRPolygon.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+OGRCURVEPOLYGON_DEF_VIRT(OGRPolygon)
+OGRSURFACE_DEF_VIRT(OGRPolygon)
+OGRGEOMETRY_DEF_VIRT(OGRPolygon)
+DELETABLE_DEF_VIRT(OGRPolygon)
+OGRPOLYGON_DEF_VIRT(OGRPolygon)
+OGRPOLYGON_DEF_NONVIRT(OGRPolygon)
+OGRPOLYGON_DEF_ACCESSOR(OGRPolygon)
+
diff --git a/csrc/HGDALOGRPolygon.h b/csrc/HGDALOGRPolygon.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRPolygon.h
@@ -0,0 +1,57 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALOGRCurvePolygon.h"
+
+#include "HGDALOGRSurface.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRPOLYGON_DECL_VIRT(Type) \
+
+
+
+#define OGRPOLYGON_DECL_NONVIRT(Type) \
+OGRLinearRing_p Type##_oGRPolygon_getExteriorRing ( Type##_p p );
+
+
+#define OGRPOLYGON_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRPOLYGON_DEF_VIRT(Type) \
+
+
+
+#define OGRPOLYGON_DEF_NONVIRT(Type) \
+OGRLinearRing_p Type##_oGRPolygon_getExteriorRing ( Type##_p p ) {\
+return from_nonconst_to_nonconst<OGRLinearRing_t, OGRLinearRing>((OGRLinearRing*)((TYPECASTMETHOD(Type, oGRPolygon_getExteriorRing, OGRPolygon))(p))->getExteriorRing());\
+}
+
+
+#define OGRPOLYGON_DEF_ACCESSOR(Type) \
+
+
+
+OGRCURVEPOLYGON_DECL_VIRT(OGRPolygon)
+OGRSURFACE_DECL_VIRT(OGRPolygon)
+OGRGEOMETRY_DECL_VIRT(OGRPolygon)
+DELETABLE_DECL_VIRT(OGRPolygon)
+OGRPOLYGON_DECL_VIRT(OGRPolygon)
+OGRPOLYGON_DECL_NONVIRT(OGRPolygon)
+OGRPOLYGON_DECL_ACCESSOR(OGRPolygon)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRSimpleCurve.cpp b/csrc/HGDALOGRSimpleCurve.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRSimpleCurve.cpp
@@ -0,0 +1,25 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRCurve.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRSimpleCurve.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+OGRCURVE_DEF_VIRT(OGRSimpleCurve)
+OGRGEOMETRY_DEF_VIRT(OGRSimpleCurve)
+DELETABLE_DEF_VIRT(OGRSimpleCurve)
+OGRSIMPLECURVE_DEF_VIRT(OGRSimpleCurve)
+OGRSIMPLECURVE_DEF_NONVIRT(OGRSimpleCurve)
+OGRSIMPLECURVE_DEF_ACCESSOR(OGRSimpleCurve)
+
diff --git a/csrc/HGDALOGRSimpleCurve.h b/csrc/HGDALOGRSimpleCurve.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRSimpleCurve.h
@@ -0,0 +1,54 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALOGRCurve.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRSIMPLECURVE_DECL_VIRT(Type) \
+
+
+
+#define OGRSIMPLECURVE_DECL_NONVIRT(Type) \
+void Type##_oGRSimpleCurve_getPoints ( Type##_p p, void* pabyX, int nXStride, void* pabyY, int nYStride, void* pabyZ, int nZStride );
+
+
+#define OGRSIMPLECURVE_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRSIMPLECURVE_DEF_VIRT(Type) \
+
+
+
+#define OGRSIMPLECURVE_DEF_NONVIRT(Type) \
+void Type##_oGRSimpleCurve_getPoints ( Type##_p p, void* pabyX, int nXStride, void* pabyY, int nYStride, void* pabyZ, int nZStride ) {\
+((TYPECASTMETHOD(Type, oGRSimpleCurve_getPoints, OGRSimpleCurve))(p))->getPoints(pabyX, nXStride, pabyY, nYStride, pabyZ, nZStride);\
+}
+
+
+#define OGRSIMPLECURVE_DEF_ACCESSOR(Type) \
+
+
+
+OGRCURVE_DECL_VIRT(OGRSimpleCurve)
+OGRGEOMETRY_DECL_VIRT(OGRSimpleCurve)
+DELETABLE_DECL_VIRT(OGRSimpleCurve)
+OGRSIMPLECURVE_DECL_VIRT(OGRSimpleCurve)
+OGRSIMPLECURVE_DECL_NONVIRT(OGRSimpleCurve)
+OGRSIMPLECURVE_DECL_ACCESSOR(OGRSimpleCurve)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/HGDALOGRSurface.cpp b/csrc/HGDALOGRSurface.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRSurface.cpp
@@ -0,0 +1,24 @@
+
+#include "MacroPatternMatch.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "ogr_geometry.h"
+
+#include "HGDALOGRSurface.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (from_nonconst_to_nonconst<oname,cname ## _t>), \
+  (from_nonconst_to_nonconst<cname,cname ## _t>) )
+
+OGRGEOMETRY_DEF_VIRT(OGRSurface)
+DELETABLE_DEF_VIRT(OGRSurface)
+OGRSURFACE_DEF_VIRT(OGRSurface)
+OGRSURFACE_DEF_NONVIRT(OGRSurface)
+OGRSURFACE_DEF_ACCESSOR(OGRSurface)
+
diff --git a/csrc/HGDALOGRSurface.h b/csrc/HGDALOGRSurface.h
new file mode 100644
--- /dev/null
+++ b/csrc/HGDALOGRSurface.h
@@ -0,0 +1,49 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALOGRGeometry.h"
+
+#include "STDDeletable.h"
+
+
+#define OGRSURFACE_DECL_VIRT(Type) \
+
+
+
+#define OGRSURFACE_DECL_NONVIRT(Type) \
+
+
+
+#define OGRSURFACE_DECL_ACCESSOR(Type) \
+
+
+
+#define OGRSURFACE_DEF_VIRT(Type) \
+
+
+
+#define OGRSURFACE_DEF_NONVIRT(Type) \
+
+
+
+#define OGRSURFACE_DEF_ACCESSOR(Type) \
+
+
+
+OGRGEOMETRY_DECL_VIRT(OGRSurface)
+DELETABLE_DECL_VIRT(OGRSurface)
+OGRSURFACE_DECL_VIRT(OGRSurface)
+OGRSURFACE_DECL_NONVIRT(OGRSurface)
+OGRSURFACE_DECL_ACCESSOR(OGRSurface)
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/hgdalTopLevel.cpp b/csrc/hgdalTopLevel.cpp
new file mode 100644
--- /dev/null
+++ b/csrc/hgdalTopLevel.cpp
@@ -0,0 +1,32 @@
+
+#include "MacroPatternMatch.h"
+
+#include "hgdalTopLevel.h"
+
+#include "HGDALOGRLayer.h"
+
+#include "HGDALGDALMajorObject.h"
+
+#include "gdal_priv.h"
+
+#include "HGDALGDALDataset.h"
+
+#include "gdal.h"
+
+
+
+#define CHECKPROTECT(x,y) FXIS_PAREN(IS_ ## x ## _ ## y ## _PROTECTED)
+
+#define TYPECASTMETHOD(cname,mname,oname) \
+  FXIIF( CHECKPROTECT(cname,mname) ) ( \
+  (to_nonconst<oname,cname ## _t>), \
+  (to_nonconst<cname,cname ## _t>) )
+
+void TopLevel_GDALAllRegister (  ) {
+GDALAllRegister();
+}
+
+GDALDataset_p TopLevel_GDALOpenEx ( const char* pszFilename, unsigned int nOpenFlags, char** papszAllowedDrivers, char** papszOpenOptions, char** papszSiblingFiles ) {
+return from_nonconst_to_nonconst<GDALDataset_t, GDALDataset>((GDALDataset*)GDALOpenEx(pszFilename, nOpenFlags, papszAllowedDrivers, papszOpenOptions, papszSiblingFiles));
+}
+
diff --git a/csrc/hgdalTopLevel.h b/csrc/hgdalTopLevel.h
new file mode 100644
--- /dev/null
+++ b/csrc/hgdalTopLevel.h
@@ -0,0 +1,17 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+
+#include "hgdalType.h"
+
+#include "HGDALGDALDataset.h"
+
+void TopLevel_GDALAllRegister (  );GDALDataset_p TopLevel_GDALOpenEx ( const char* pszFilename, unsigned int nOpenFlags, char** papszAllowedDrivers, char** papszOpenOptions, char** papszSiblingFiles );
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/csrc/hgdalType.h b/csrc/hgdalType.h
new file mode 100644
--- /dev/null
+++ b/csrc/hgdalType.h
@@ -0,0 +1,51 @@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma once
+
+// Opaque type definition for $classname
+typedef struct GDALDataset_tag GDALDataset_t;typedef GDALDataset_t * GDALDataset_p;typedef GDALDataset_t const* const_GDALDataset_p;
+// Opaque type definition for $classname
+typedef struct GDALMajorObject_tag GDALMajorObject_t;typedef GDALMajorObject_t * GDALMajorObject_p;typedef GDALMajorObject_t const* const_GDALMajorObject_p;
+// Opaque type definition for $classname
+typedef struct OGRCurve_tag OGRCurve_t;typedef OGRCurve_t * OGRCurve_p;typedef OGRCurve_t const* const_OGRCurve_p;
+// Opaque type definition for $classname
+typedef struct OGRCurvePolygon_tag OGRCurvePolygon_t;typedef OGRCurvePolygon_t * OGRCurvePolygon_p;typedef OGRCurvePolygon_t const* const_OGRCurvePolygon_p;
+// Opaque type definition for $classname
+typedef struct OGREnvelope_tag OGREnvelope_t;typedef OGREnvelope_t * OGREnvelope_p;typedef OGREnvelope_t const* const_OGREnvelope_p;
+// Opaque type definition for $classname
+typedef struct OGRFeature_tag OGRFeature_t;typedef OGRFeature_t * OGRFeature_p;typedef OGRFeature_t const* const_OGRFeature_p;
+// Opaque type definition for $classname
+typedef struct OGRFeatureDefn_tag OGRFeatureDefn_t;typedef OGRFeatureDefn_t * OGRFeatureDefn_p;typedef OGRFeatureDefn_t const* const_OGRFeatureDefn_p;
+// Opaque type definition for $classname
+typedef struct OGRFieldDefn_tag OGRFieldDefn_t;typedef OGRFieldDefn_t * OGRFieldDefn_p;typedef OGRFieldDefn_t const* const_OGRFieldDefn_p;
+// Opaque type definition for $classname
+typedef struct OGRGeometry_tag OGRGeometry_t;typedef OGRGeometry_t * OGRGeometry_p;typedef OGRGeometry_t const* const_OGRGeometry_p;
+// Opaque type definition for $classname
+typedef struct OGRGeometryCollection_tag OGRGeometryCollection_t;typedef OGRGeometryCollection_t * OGRGeometryCollection_p;typedef OGRGeometryCollection_t const* const_OGRGeometryCollection_p;
+// Opaque type definition for $classname
+typedef struct OGRLayer_tag OGRLayer_t;typedef OGRLayer_t * OGRLayer_p;typedef OGRLayer_t const* const_OGRLayer_p;
+// Opaque type definition for $classname
+typedef struct OGRLinearRing_tag OGRLinearRing_t;typedef OGRLinearRing_t * OGRLinearRing_p;typedef OGRLinearRing_t const* const_OGRLinearRing_p;
+// Opaque type definition for $classname
+typedef struct OGRLineString_tag OGRLineString_t;typedef OGRLineString_t * OGRLineString_p;typedef OGRLineString_t const* const_OGRLineString_p;
+// Opaque type definition for $classname
+typedef struct OGRMultiPolygon_tag OGRMultiPolygon_t;typedef OGRMultiPolygon_t * OGRMultiPolygon_p;typedef OGRMultiPolygon_t const* const_OGRMultiPolygon_p;
+// Opaque type definition for $classname
+typedef struct OGRMultiSurface_tag OGRMultiSurface_t;typedef OGRMultiSurface_t * OGRMultiSurface_p;typedef OGRMultiSurface_t const* const_OGRMultiSurface_p;
+// Opaque type definition for $classname
+typedef struct OGRPoint_tag OGRPoint_t;typedef OGRPoint_t * OGRPoint_p;typedef OGRPoint_t const* const_OGRPoint_p;
+// Opaque type definition for $classname
+typedef struct OGRPointIterator_tag OGRPointIterator_t;typedef OGRPointIterator_t * OGRPointIterator_p;typedef OGRPointIterator_t const* const_OGRPointIterator_p;
+// Opaque type definition for $classname
+typedef struct OGRPolygon_tag OGRPolygon_t;typedef OGRPolygon_t * OGRPolygon_p;typedef OGRPolygon_t const* const_OGRPolygon_p;
+// Opaque type definition for $classname
+typedef struct OGRSimpleCurve_tag OGRSimpleCurve_t;typedef OGRSimpleCurve_t * OGRSimpleCurve_p;typedef OGRSimpleCurve_t const* const_OGRSimpleCurve_p;
+// Opaque type definition for $classname
+typedef struct OGRSurface_tag OGRSurface_t;typedef OGRSurface_t * OGRSurface_p;typedef OGRSurface_t const* const_OGRSurface_p;
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/hgdal.cabal b/hgdal.cabal
new file mode 100644
--- /dev/null
+++ b/hgdal.cabal
@@ -0,0 +1,245 @@
+Cabal-version: 3.0
+Name:          hgdal
+Version:       1.0.0.0
+Synopsis:      Haskell binding to the GDAL library
+Description:
+  GDAL is a translator library for raster and vector geospatial data formats that is released under an X/MIT
+  style Open Source License by the Open Source Geospatial Foundation.
+  hgdal is Haskell binidng to the GDAL C++ library generated by fficxx.
+Homepage:      https://wavewave.github.io/hgdal
+license:       BSD-2-Clause
+license-file:  LICENSE
+Author:        Ian-Woo Kim 
+Maintainer:    Ian-Woo Kim <ianwookim@gmail.com>
+Category:      Geography
+Tested-with:   GHC == 9.0.2 || == 9.2.4 || == 9.4.2 
+Build-Type:    Simple
+Extra-source-files:
+  ChangeLog.md
+  csrc/hgdalTopLevel.h
+  csrc/HGDALGDALDataset.h
+  csrc/HGDALGDALMajorObject.h
+  csrc/HGDALOGRCurve.h
+  csrc/HGDALOGRCurvePolygon.h
+  csrc/HGDALOGREnvelope.h
+  csrc/HGDALOGRFeature.h
+  csrc/HGDALOGRFeatureDefn.h
+  csrc/HGDALOGRFieldDefn.h
+  csrc/HGDALOGRGeometry.h
+  csrc/HGDALOGRGeometryCollection.h
+  csrc/HGDALOGRLayer.h
+  csrc/HGDALOGRLinearRing.h
+  csrc/HGDALOGRLineString.h
+  csrc/HGDALOGRMultiPolygon.h
+  csrc/HGDALOGRMultiSurface.h
+  csrc/HGDALOGRPoint.h
+  csrc/HGDALOGRPointIterator.h
+  csrc/HGDALOGRPolygon.h
+  csrc/HGDALOGRSimpleCurve.h
+  csrc/HGDALOGRSurface.h
+  csrc/hgdalTopLevel.cpp
+  csrc/HGDALGDALDataset.cpp
+  csrc/HGDALGDALMajorObject.cpp
+  csrc/HGDALOGRCurve.cpp
+  csrc/HGDALOGRCurvePolygon.cpp
+  csrc/HGDALOGREnvelope.cpp
+  csrc/HGDALOGRFeature.cpp
+  csrc/HGDALOGRFeatureDefn.cpp
+  csrc/HGDALOGRFieldDefn.cpp
+  csrc/HGDALOGRGeometry.cpp
+  csrc/HGDALOGRGeometryCollection.cpp
+  csrc/HGDALOGRLayer.cpp
+  csrc/HGDALOGRLinearRing.cpp
+  csrc/HGDALOGRLineString.cpp
+  csrc/HGDALOGRMultiPolygon.cpp
+  csrc/HGDALOGRMultiSurface.cpp
+  csrc/HGDALOGRPoint.cpp
+  csrc/HGDALOGRPointIterator.cpp
+  csrc/HGDALOGRPolygon.cpp
+  csrc/HGDALOGRSimpleCurve.cpp
+  csrc/HGDALOGRSurface.cpp
+
+Source-repository head
+  type:     git
+  location: https://github.com/wavewave/hgdal
+  
+Library
+  default-language: Haskell2010
+  hs-source-dirs: src
+  ghc-options:  -Wall -funbox-strict-fields -fno-warn-unused-do-bind -fno-warn-orphans -fno-warn-unused-imports
+  cxx-options: -std=c++17
+  Build-Depends: base > 4 && < 5, fficxx >= 0.7, fficxx-runtime >= 0.7, template-haskell, stdcxx
+  Exposed-Modules:
+                       GDAL
+                       GDAL.Ordinary
+                       GDAL.Template
+                       GDAL.TH
+                       GDAL.GDALDataset
+                       GDAL.GDALMajorObject
+                       GDAL.OGRCurve
+                       GDAL.OGRCurvePolygon
+                       GDAL.OGREnvelope
+                       GDAL.OGRFeature
+                       GDAL.OGRFeatureDefn
+                       GDAL.OGRFieldDefn
+                       GDAL.OGRGeometry
+                       GDAL.OGRGeometryCollection
+                       GDAL.OGRLayer
+                       GDAL.OGRLinearRing
+                       GDAL.OGRLineString
+                       GDAL.OGRMultiPolygon
+                       GDAL.OGRMultiSurface
+                       GDAL.OGRPoint
+                       GDAL.OGRPointIterator
+                       GDAL.OGRPolygon
+                       GDAL.OGRSimpleCurve
+                       GDAL.OGRSurface
+                       GDAL.GDALDataset.RawType
+                       GDAL.GDALMajorObject.RawType
+                       GDAL.OGRCurve.RawType
+                       GDAL.OGRCurvePolygon.RawType
+                       GDAL.OGREnvelope.RawType
+                       GDAL.OGRFeature.RawType
+                       GDAL.OGRFeatureDefn.RawType
+                       GDAL.OGRFieldDefn.RawType
+                       GDAL.OGRGeometry.RawType
+                       GDAL.OGRGeometryCollection.RawType
+                       GDAL.OGRLayer.RawType
+                       GDAL.OGRLinearRing.RawType
+                       GDAL.OGRLineString.RawType
+                       GDAL.OGRMultiPolygon.RawType
+                       GDAL.OGRMultiSurface.RawType
+                       GDAL.OGRPoint.RawType
+                       GDAL.OGRPointIterator.RawType
+                       GDAL.OGRPolygon.RawType
+                       GDAL.OGRSimpleCurve.RawType
+                       GDAL.OGRSurface.RawType
+                       GDAL.GDALDataset.FFI
+                       GDAL.GDALMajorObject.FFI
+                       GDAL.OGRCurve.FFI
+                       GDAL.OGRCurvePolygon.FFI
+                       GDAL.OGREnvelope.FFI
+                       GDAL.OGRFeature.FFI
+                       GDAL.OGRFeatureDefn.FFI
+                       GDAL.OGRFieldDefn.FFI
+                       GDAL.OGRGeometry.FFI
+                       GDAL.OGRGeometryCollection.FFI
+                       GDAL.OGRLayer.FFI
+                       GDAL.OGRLinearRing.FFI
+                       GDAL.OGRLineString.FFI
+                       GDAL.OGRMultiPolygon.FFI
+                       GDAL.OGRMultiSurface.FFI
+                       GDAL.OGRPoint.FFI
+                       GDAL.OGRPointIterator.FFI
+                       GDAL.OGRPolygon.FFI
+                       GDAL.OGRSimpleCurve.FFI
+                       GDAL.OGRSurface.FFI
+                       GDAL.GDALDataset.Interface
+                       GDAL.GDALMajorObject.Interface
+                       GDAL.OGRCurve.Interface
+                       GDAL.OGRCurvePolygon.Interface
+                       GDAL.OGREnvelope.Interface
+                       GDAL.OGRFeature.Interface
+                       GDAL.OGRFeatureDefn.Interface
+                       GDAL.OGRFieldDefn.Interface
+                       GDAL.OGRGeometry.Interface
+                       GDAL.OGRGeometryCollection.Interface
+                       GDAL.OGRLayer.Interface
+                       GDAL.OGRLinearRing.Interface
+                       GDAL.OGRLineString.Interface
+                       GDAL.OGRMultiPolygon.Interface
+                       GDAL.OGRMultiSurface.Interface
+                       GDAL.OGRPoint.Interface
+                       GDAL.OGRPointIterator.Interface
+                       GDAL.OGRPolygon.Interface
+                       GDAL.OGRSimpleCurve.Interface
+                       GDAL.OGRSurface.Interface
+                       GDAL.GDALDataset.Cast
+                       GDAL.GDALMajorObject.Cast
+                       GDAL.OGRCurve.Cast
+                       GDAL.OGRCurvePolygon.Cast
+                       GDAL.OGREnvelope.Cast
+                       GDAL.OGRFeature.Cast
+                       GDAL.OGRFeatureDefn.Cast
+                       GDAL.OGRFieldDefn.Cast
+                       GDAL.OGRGeometry.Cast
+                       GDAL.OGRGeometryCollection.Cast
+                       GDAL.OGRLayer.Cast
+                       GDAL.OGRLinearRing.Cast
+                       GDAL.OGRLineString.Cast
+                       GDAL.OGRMultiPolygon.Cast
+                       GDAL.OGRMultiSurface.Cast
+                       GDAL.OGRPoint.Cast
+                       GDAL.OGRPointIterator.Cast
+                       GDAL.OGRPolygon.Cast
+                       GDAL.OGRSimpleCurve.Cast
+                       GDAL.OGRSurface.Cast
+                       GDAL.GDALDataset.Implementation
+                       GDAL.GDALMajorObject.Implementation
+                       GDAL.OGRCurve.Implementation
+                       GDAL.OGRCurvePolygon.Implementation
+                       GDAL.OGREnvelope.Implementation
+                       GDAL.OGRFeature.Implementation
+                       GDAL.OGRFeatureDefn.Implementation
+                       GDAL.OGRFieldDefn.Implementation
+                       GDAL.OGRGeometry.Implementation
+                       GDAL.OGRGeometryCollection.Implementation
+                       GDAL.OGRLayer.Implementation
+                       GDAL.OGRLinearRing.Implementation
+                       GDAL.OGRLineString.Implementation
+                       GDAL.OGRMultiPolygon.Implementation
+                       GDAL.OGRMultiSurface.Implementation
+                       GDAL.OGRPoint.Implementation
+                       GDAL.OGRPointIterator.Implementation
+                       GDAL.OGRPolygon.Implementation
+                       GDAL.OGRSimpleCurve.Implementation
+                       GDAL.OGRSurface.Implementation
+  Other-Modules:
+  extra-lib-dirs: 
+  extra-libraries:    
+  Include-dirs:       csrc 
+  pkgconfig-depends: gdal
+  Install-includes:
+                       hgdalType.h
+                       HGDALGDALDataset.h
+                       HGDALGDALMajorObject.h
+                       HGDALOGRCurve.h
+                       HGDALOGRCurvePolygon.h
+                       HGDALOGREnvelope.h
+                       HGDALOGRFeature.h
+                       HGDALOGRFeatureDefn.h
+                       HGDALOGRFieldDefn.h
+                       HGDALOGRGeometry.h
+                       HGDALOGRGeometryCollection.h
+                       HGDALOGRLayer.h
+                       HGDALOGRLinearRing.h
+                       HGDALOGRLineString.h
+                       HGDALOGRMultiPolygon.h
+                       HGDALOGRMultiSurface.h
+                       HGDALOGRPoint.h
+                       HGDALOGRPointIterator.h
+                       HGDALOGRPolygon.h
+                       HGDALOGRSimpleCurve.h
+                       HGDALOGRSurface.h
+  Cxx-sources:
+                       csrc/hgdalTopLevel.cpp
+                       csrc/HGDALGDALDataset.cpp
+                       csrc/HGDALGDALMajorObject.cpp
+                       csrc/HGDALOGRCurve.cpp
+                       csrc/HGDALOGRCurvePolygon.cpp
+                       csrc/HGDALOGREnvelope.cpp
+                       csrc/HGDALOGRFeature.cpp
+                       csrc/HGDALOGRFeatureDefn.cpp
+                       csrc/HGDALOGRFieldDefn.cpp
+                       csrc/HGDALOGRGeometry.cpp
+                       csrc/HGDALOGRGeometryCollection.cpp
+                       csrc/HGDALOGRLayer.cpp
+                       csrc/HGDALOGRLinearRing.cpp
+                       csrc/HGDALOGRLineString.cpp
+                       csrc/HGDALOGRMultiPolygon.cpp
+                       csrc/HGDALOGRMultiSurface.cpp
+                       csrc/HGDALOGRPoint.cpp
+                       csrc/HGDALOGRPointIterator.cpp
+                       csrc/HGDALOGRPolygon.cpp
+                       csrc/HGDALOGRSimpleCurve.cpp
+                       csrc/HGDALOGRSurface.cpp
diff --git a/src/GDAL.hs b/src/GDAL.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL.hs
@@ -0,0 +1,38 @@
+{-# LANGUAGE FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL
+       (module GDAL.GDALDataset, module GDAL.GDALMajorObject,
+        module GDAL.OGRCurve, module GDAL.OGRCurvePolygon,
+        module GDAL.OGREnvelope, module GDAL.OGRFeature,
+        module GDAL.OGRFeatureDefn, module GDAL.OGRFieldDefn,
+        module GDAL.OGRGeometry, module GDAL.OGRGeometryCollection,
+        module GDAL.OGRLayer, module GDAL.OGRLinearRing,
+        module GDAL.OGRLineString, module GDAL.OGRMultiPolygon,
+        module GDAL.OGRMultiSurface, module GDAL.OGRPoint,
+        module GDAL.OGRPointIterator, module GDAL.OGRPolygon,
+        module GDAL.OGRSimpleCurve, module GDAL.OGRSurface,
+        module GDAL.Ordinary, module GDAL.Template, module GDAL.TH)
+       where
+import GDAL.GDALDataset
+import GDAL.GDALMajorObject
+import GDAL.OGRCurve
+import GDAL.OGRCurvePolygon
+import GDAL.OGREnvelope
+import GDAL.OGRFeature
+import GDAL.OGRFeatureDefn
+import GDAL.OGRFieldDefn
+import GDAL.OGRGeometry
+import GDAL.OGRGeometryCollection
+import GDAL.OGRLayer
+import GDAL.OGRLinearRing
+import GDAL.OGRLineString
+import GDAL.OGRMultiPolygon
+import GDAL.OGRMultiSurface
+import GDAL.OGRPoint
+import GDAL.OGRPointIterator
+import GDAL.OGRPolygon
+import GDAL.OGRSimpleCurve
+import GDAL.OGRSurface
+import GDAL.Template
+import GDAL.TH
+import GDAL.Ordinary
diff --git a/src/GDAL/GDALDataset.hs b/src/GDAL/GDALDataset.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALDataset.hs
@@ -0,0 +1,7 @@
+module GDAL.GDALDataset
+       (GDALDataset(..), IGDALDataset(..), upcastGDALDataset,
+        downcastGDALDataset)
+       where
+import GDAL.GDALDataset.RawType
+import GDAL.GDALDataset.Interface
+import GDAL.GDALDataset.Implementation
diff --git a/src/GDAL/GDALDataset/Cast.hs b/src/GDAL/GDALDataset/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALDataset/Cast.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.GDALDataset.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.GDALDataset.RawType
+import GDAL.GDALDataset.Interface
+
+instance (IGDALDataset a, FPtr a) =>
+         Castable (a) (Ptr RawGDALDataset)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (GDALDataset) (Ptr RawGDALDataset) where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/GDALDataset/FFI.hsc b/src/GDAL/GDALDataset/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALDataset/FFI.hsc
@@ -0,0 +1,21 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.GDALDataset.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.GDALDataset.RawType
+import GDAL.GDALDataset.RawType
+import GDAL.OGRLayer.RawType
+
+foreign import ccall interruptible
+               "HGDALGDALDataset.h GDALDataset_delete" c_gdaldataset_delete ::
+               Ptr RawGDALDataset -> IO ()
+
+foreign import ccall interruptible
+               "HGDALGDALDataset.h GDALDataset_GetLayer" c_gdaldataset_getlayer ::
+               Ptr RawGDALDataset -> CInt -> IO (Ptr RawOGRLayer)
+
+foreign import ccall interruptible
+               "HGDALGDALDataset.h GDALDataset_GetLayerCount"
+               c_gdaldataset_getlayercount :: Ptr RawGDALDataset -> IO CInt
diff --git a/src/GDAL/GDALDataset/Implementation.hs b/src/GDAL/GDALDataset/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALDataset/Implementation.hs
@@ -0,0 +1,41 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.GDALDataset.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.GDALDataset.RawType
+import GDAL.GDALDataset.FFI
+import GDAL.GDALDataset.Interface
+import GDAL.GDALDataset.Cast
+import GDAL.GDALDataset.RawType
+import GDAL.GDALDataset.Cast
+import GDAL.GDALDataset.Interface
+import GDAL.OGRLayer.RawType
+import GDAL.OGRLayer.Cast
+import GDAL.OGRLayer.Interface
+import GDAL.GDALMajorObject.RawType
+import GDAL.GDALMajorObject.Cast
+import GDAL.GDALMajorObject.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IGDALDataset (GDALDataset) where
+        getLayer = xform1 c_gdaldataset_getlayer
+        getLayerCount = xform0 c_gdaldataset_getlayercount
+
+instance () => IGDALMajorObject (GDALDataset) where
+
+instance () => IDeletable (GDALDataset) where
+        delete = xform0 c_gdaldataset_delete
diff --git a/src/GDAL/GDALDataset/Interface.hs b/src/GDAL/GDALDataset/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALDataset/Interface.hs
@@ -0,0 +1,32 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.GDALDataset.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.GDALDataset.RawType
+import GDAL.OGRLayer.RawType
+import GDAL.GDALMajorObject.Interface
+
+class (IGDALMajorObject a) => IGDALDataset a where
+        getLayer :: () => a -> CInt -> IO OGRLayer
+        
+        getLayerCount :: () => a -> IO CInt
+
+upcastGDALDataset ::
+                  forall a . (FPtr a, IGDALDataset a) => a -> GDALDataset
+upcastGDALDataset h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawGDALDataset = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastGDALDataset ::
+                    forall a . (FPtr a, IGDALDataset a) => GDALDataset -> a
+downcastGDALDataset h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/GDALDataset/RawType.hs b/src/GDAL/GDALDataset/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALDataset/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.GDALDataset.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawGDALDataset
+
+newtype GDALDataset = GDALDataset (Ptr RawGDALDataset)
+                        deriving (Eq, Ord, Show)
+
+instance () => FPtr (GDALDataset) where
+        type Raw GDALDataset = RawGDALDataset
+        get_fptr (GDALDataset ptr) = ptr
+        cast_fptr_to_obj = GDALDataset
diff --git a/src/GDAL/GDALMajorObject.hs b/src/GDAL/GDALMajorObject.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALMajorObject.hs
@@ -0,0 +1,7 @@
+module GDAL.GDALMajorObject
+       (GDALMajorObject(..), IGDALMajorObject, upcastGDALMajorObject,
+        downcastGDALMajorObject)
+       where
+import GDAL.GDALMajorObject.RawType
+import GDAL.GDALMajorObject.Interface
+import GDAL.GDALMajorObject.Implementation
diff --git a/src/GDAL/GDALMajorObject/Cast.hs b/src/GDAL/GDALMajorObject/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALMajorObject/Cast.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.GDALMajorObject.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.GDALMajorObject.RawType
+import GDAL.GDALMajorObject.Interface
+
+instance (IGDALMajorObject a, FPtr a) =>
+         Castable (a) (Ptr RawGDALMajorObject)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (GDALMajorObject) (Ptr RawGDALMajorObject)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/GDALMajorObject/FFI.hsc b/src/GDAL/GDALMajorObject/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALMajorObject/FFI.hsc
@@ -0,0 +1,12 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.GDALMajorObject.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.GDALMajorObject.RawType
+import GDAL.GDALMajorObject.RawType
+
+foreign import ccall interruptible
+               "HGDALGDALMajorObject.h GDALMajorObject_delete"
+               c_gdalmajorobject_delete :: Ptr RawGDALMajorObject -> IO ()
diff --git a/src/GDAL/GDALMajorObject/Implementation.hs b/src/GDAL/GDALMajorObject/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALMajorObject/Implementation.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.GDALMajorObject.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.GDALMajorObject.RawType
+import GDAL.GDALMajorObject.FFI
+import GDAL.GDALMajorObject.Interface
+import GDAL.GDALMajorObject.Cast
+import GDAL.GDALMajorObject.RawType
+import GDAL.GDALMajorObject.Cast
+import GDAL.GDALMajorObject.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IGDALMajorObject (GDALMajorObject) where
+
+instance () => IDeletable (GDALMajorObject) where
+        delete = xform0 c_gdalmajorobject_delete
diff --git a/src/GDAL/GDALMajorObject/Interface.hs b/src/GDAL/GDALMajorObject/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALMajorObject/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.GDALMajorObject.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.GDALMajorObject.RawType
+import STD.Deletable.Interface
+
+class (IDeletable a) => IGDALMajorObject a where
+
+upcastGDALMajorObject ::
+                      forall a . (FPtr a, IGDALMajorObject a) => a -> GDALMajorObject
+upcastGDALMajorObject h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawGDALMajorObject = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastGDALMajorObject ::
+                        forall a . (FPtr a, IGDALMajorObject a) => GDALMajorObject -> a
+downcastGDALMajorObject h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/GDALMajorObject/RawType.hs b/src/GDAL/GDALMajorObject/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/GDALMajorObject/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.GDALMajorObject.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawGDALMajorObject
+
+newtype GDALMajorObject = GDALMajorObject (Ptr RawGDALMajorObject)
+                            deriving (Eq, Ord, Show)
+
+instance () => FPtr (GDALMajorObject) where
+        type Raw GDALMajorObject = RawGDALMajorObject
+        get_fptr (GDALMajorObject ptr) = ptr
+        cast_fptr_to_obj = GDALMajorObject
diff --git a/src/GDAL/OGRCurve.hs b/src/GDAL/OGRCurve.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurve.hs
@@ -0,0 +1,6 @@
+module GDAL.OGRCurve
+       (OGRCurve(..), IOGRCurve(..), upcastOGRCurve, downcastOGRCurve)
+       where
+import GDAL.OGRCurve.RawType
+import GDAL.OGRCurve.Interface
+import GDAL.OGRCurve.Implementation
diff --git a/src/GDAL/OGRCurve/Cast.hs b/src/GDAL/OGRCurve/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurve/Cast.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRCurve.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRCurve.RawType
+import GDAL.OGRCurve.Interface
+
+instance (IOGRCurve a, FPtr a) => Castable (a) (Ptr RawOGRCurve)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRCurve) (Ptr RawOGRCurve) where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRCurve/FFI.hsc b/src/GDAL/OGRCurve/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurve/FFI.hsc
@@ -0,0 +1,124 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRCurve.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRCurve.RawType
+import GDAL.OGRCurve.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGREnvelope.RawType
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPointIterator.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_getGeometryType"
+               c_ogrcurve_getgeometrytype :: Ptr RawOGRCurve -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_getEnvelope" c_ogrcurve_getenvelope ::
+               Ptr RawOGRCurve -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Intersects" c_ogrcurve_intersects ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Equals" c_ogrcurve_equals ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Disjoint" c_ogrcurve_disjoint ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Touches" c_ogrcurve_touches ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Crosses" c_ogrcurve_crosses ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Within" c_ogrcurve_within ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Contains" c_ogrcurve_contains ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Overlaps" c_ogrcurve_overlaps ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Boundary" c_ogrcurve_boundary ::
+               Ptr RawOGRCurve -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Distance" c_ogrcurve_distance ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_ConvexHull" c_ogrcurve_convexhull ::
+               Ptr RawOGRCurve -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Buffer" c_ogrcurve_buffer ::
+               Ptr RawOGRCurve -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Intersection" c_ogrcurve_intersection ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible "HGDALOGRCurve.h OGRCurve_Union"
+               c_ogrcurve_union ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_UnionCascaded" c_ogrcurve_unioncascaded
+               :: Ptr RawOGRCurve -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Difference" c_ogrcurve_difference ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_SymDifference" c_ogrcurve_symdifference
+               :: Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Centroid" c_ogrcurve_centroid ::
+               Ptr RawOGRCurve -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Simplify" c_ogrcurve_simplify ::
+               Ptr RawOGRCurve -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_DelaunayTriangulation"
+               c_ogrcurve_delaunaytriangulation ::
+               Ptr RawOGRCurve -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Polygonize" c_ogrcurve_polygonize ::
+               Ptr RawOGRCurve -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_Distance3D" c_ogrcurve_distance3d ::
+               Ptr RawOGRCurve -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_delete" c_ogrcurve_delete ::
+               Ptr RawOGRCurve -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_getNumPoints" c_ogrcurve_getnumpoints ::
+               Ptr RawOGRCurve -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRCurve.h OGRCurve_getPointIterator"
+               c_ogrcurve_getpointiterator ::
+               Ptr RawOGRCurve -> IO (Ptr RawOGRPointIterator)
diff --git a/src/GDAL/OGRCurve/Implementation.hs b/src/GDAL/OGRCurve/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurve/Implementation.hs
@@ -0,0 +1,77 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRCurve.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRCurve.RawType
+import GDAL.OGRCurve.FFI
+import GDAL.OGRCurve.Interface
+import GDAL.OGRCurve.Cast
+import GDAL.OGRCurve.RawType
+import GDAL.OGRCurve.Cast
+import GDAL.OGRCurve.Interface
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRPointIterator.Cast
+import GDAL.OGRPointIterator.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRCurve (OGRCurve) where
+        getNumPoints = xform0 c_ogrcurve_getnumpoints
+        getPointIterator = xform0 c_ogrcurve_getpointiterator
+
+instance () => IOGRGeometry (OGRCurve) where
+        getGeometryType = xform0 c_ogrcurve_getgeometrytype
+        getEnvelope = xform1 c_ogrcurve_getenvelope
+        intersects = xform1 c_ogrcurve_intersects
+        equals = xform1 c_ogrcurve_equals
+        disjoint = xform1 c_ogrcurve_disjoint
+        touches = xform1 c_ogrcurve_touches
+        crosses = xform1 c_ogrcurve_crosses
+        within = xform1 c_ogrcurve_within
+        contains = xform1 c_ogrcurve_contains
+        overlaps = xform1 c_ogrcurve_overlaps
+        boundary = xform0 c_ogrcurve_boundary
+        distance = xform1 c_ogrcurve_distance
+        convexHull = xform0 c_ogrcurve_convexhull
+        buffer = xform2 c_ogrcurve_buffer
+        intersection = xform1 c_ogrcurve_intersection
+        union = xform1 c_ogrcurve_union
+        unionCascaded = xform0 c_ogrcurve_unioncascaded
+        difference = xform1 c_ogrcurve_difference
+        symDifference = xform1 c_ogrcurve_symdifference
+        centroid = xform1 c_ogrcurve_centroid
+        simplify = xform1 c_ogrcurve_simplify
+        delaunayTriangulation = xform2 c_ogrcurve_delaunaytriangulation
+        polygonize = xform0 c_ogrcurve_polygonize
+        distance3D = xform1 c_ogrcurve_distance3d
+
+instance () => IDeletable (OGRCurve) where
+        delete = xform0 c_ogrcurve_delete
diff --git a/src/GDAL/OGRCurve/Interface.hs b/src/GDAL/OGRCurve/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurve/Interface.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRCurve.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRCurve.RawType
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRGeometry.Interface
+
+class (IOGRGeometry a) => IOGRCurve a where
+        getNumPoints :: () => a -> IO CInt
+        
+        getPointIterator :: () => a -> IO OGRPointIterator
+
+upcastOGRCurve :: forall a . (FPtr a, IOGRCurve a) => a -> OGRCurve
+upcastOGRCurve h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRCurve = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRCurve ::
+                 forall a . (FPtr a, IOGRCurve a) => OGRCurve -> a
+downcastOGRCurve h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRCurve/RawType.hs b/src/GDAL/OGRCurve/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurve/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRCurve.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRCurve
+
+newtype OGRCurve = OGRCurve (Ptr RawOGRCurve)
+                     deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRCurve) where
+        type Raw OGRCurve = RawOGRCurve
+        get_fptr (OGRCurve ptr) = ptr
+        cast_fptr_to_obj = OGRCurve
diff --git a/src/GDAL/OGRCurvePolygon.hs b/src/GDAL/OGRCurvePolygon.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurvePolygon.hs
@@ -0,0 +1,7 @@
+module GDAL.OGRCurvePolygon
+       (OGRCurvePolygon(..), IOGRCurvePolygon, upcastOGRCurvePolygon,
+        downcastOGRCurvePolygon)
+       where
+import GDAL.OGRCurvePolygon.RawType
+import GDAL.OGRCurvePolygon.Interface
+import GDAL.OGRCurvePolygon.Implementation
diff --git a/src/GDAL/OGRCurvePolygon/Cast.hs b/src/GDAL/OGRCurvePolygon/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurvePolygon/Cast.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRCurvePolygon.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRCurvePolygon.RawType
+import GDAL.OGRCurvePolygon.Interface
+
+instance (IOGRCurvePolygon a, FPtr a) =>
+         Castable (a) (Ptr RawOGRCurvePolygon)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRCurvePolygon) (Ptr RawOGRCurvePolygon)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRCurvePolygon/FFI.hsc b/src/GDAL/OGRCurvePolygon/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurvePolygon/FFI.hsc
@@ -0,0 +1,143 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRCurvePolygon.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRCurvePolygon.RawType
+import GDAL.OGRCurvePolygon.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGREnvelope.RawType
+import GDAL.OGRPoint.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_getGeometryType"
+               c_ogrcurvepolygon_getgeometrytype ::
+               Ptr RawOGRCurvePolygon -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_getEnvelope"
+               c_ogrcurvepolygon_getenvelope ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Intersects"
+               c_ogrcurvepolygon_intersects ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Equals"
+               c_ogrcurvepolygon_equals ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Disjoint"
+               c_ogrcurvepolygon_disjoint ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Touches"
+               c_ogrcurvepolygon_touches ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Crosses"
+               c_ogrcurvepolygon_crosses ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Within"
+               c_ogrcurvepolygon_within ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Contains"
+               c_ogrcurvepolygon_contains ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Overlaps"
+               c_ogrcurvepolygon_overlaps ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Boundary"
+               c_ogrcurvepolygon_boundary ::
+               Ptr RawOGRCurvePolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Distance"
+               c_ogrcurvepolygon_distance ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_ConvexHull"
+               c_ogrcurvepolygon_convexhull ::
+               Ptr RawOGRCurvePolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Buffer"
+               c_ogrcurvepolygon_buffer ::
+               Ptr RawOGRCurvePolygon ->
+                 CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Intersection"
+               c_ogrcurvepolygon_intersection ::
+               Ptr RawOGRCurvePolygon ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Union"
+               c_ogrcurvepolygon_union ::
+               Ptr RawOGRCurvePolygon ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_UnionCascaded"
+               c_ogrcurvepolygon_unioncascaded ::
+               Ptr RawOGRCurvePolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Difference"
+               c_ogrcurvepolygon_difference ::
+               Ptr RawOGRCurvePolygon ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_SymDifference"
+               c_ogrcurvepolygon_symdifference ::
+               Ptr RawOGRCurvePolygon ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Centroid"
+               c_ogrcurvepolygon_centroid ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Simplify"
+               c_ogrcurvepolygon_simplify ::
+               Ptr RawOGRCurvePolygon -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_DelaunayTriangulation"
+               c_ogrcurvepolygon_delaunaytriangulation ::
+               Ptr RawOGRCurvePolygon ->
+                 CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Polygonize"
+               c_ogrcurvepolygon_polygonize ::
+               Ptr RawOGRCurvePolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_Distance3D"
+               c_ogrcurvepolygon_distance3d ::
+               Ptr RawOGRCurvePolygon -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRCurvePolygon.h OGRCurvePolygon_delete"
+               c_ogrcurvepolygon_delete :: Ptr RawOGRCurvePolygon -> IO ()
diff --git a/src/GDAL/OGRCurvePolygon/Implementation.hs b/src/GDAL/OGRCurvePolygon/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurvePolygon/Implementation.hs
@@ -0,0 +1,78 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRCurvePolygon.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRCurvePolygon.RawType
+import GDAL.OGRCurvePolygon.FFI
+import GDAL.OGRCurvePolygon.Interface
+import GDAL.OGRCurvePolygon.Cast
+import GDAL.OGRCurvePolygon.RawType
+import GDAL.OGRCurvePolygon.Cast
+import GDAL.OGRCurvePolygon.Interface
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import GDAL.OGRSurface.RawType
+import GDAL.OGRSurface.Cast
+import GDAL.OGRSurface.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRCurvePolygon (OGRCurvePolygon) where
+
+instance () => IOGRSurface (OGRCurvePolygon) where
+
+instance () => IOGRGeometry (OGRCurvePolygon) where
+        getGeometryType = xform0 c_ogrcurvepolygon_getgeometrytype
+        getEnvelope = xform1 c_ogrcurvepolygon_getenvelope
+        intersects = xform1 c_ogrcurvepolygon_intersects
+        equals = xform1 c_ogrcurvepolygon_equals
+        disjoint = xform1 c_ogrcurvepolygon_disjoint
+        touches = xform1 c_ogrcurvepolygon_touches
+        crosses = xform1 c_ogrcurvepolygon_crosses
+        within = xform1 c_ogrcurvepolygon_within
+        contains = xform1 c_ogrcurvepolygon_contains
+        overlaps = xform1 c_ogrcurvepolygon_overlaps
+        boundary = xform0 c_ogrcurvepolygon_boundary
+        distance = xform1 c_ogrcurvepolygon_distance
+        convexHull = xform0 c_ogrcurvepolygon_convexhull
+        buffer = xform2 c_ogrcurvepolygon_buffer
+        intersection = xform1 c_ogrcurvepolygon_intersection
+        union = xform1 c_ogrcurvepolygon_union
+        unionCascaded = xform0 c_ogrcurvepolygon_unioncascaded
+        difference = xform1 c_ogrcurvepolygon_difference
+        symDifference = xform1 c_ogrcurvepolygon_symdifference
+        centroid = xform1 c_ogrcurvepolygon_centroid
+        simplify = xform1 c_ogrcurvepolygon_simplify
+        delaunayTriangulation
+          = xform2 c_ogrcurvepolygon_delaunaytriangulation
+        polygonize = xform0 c_ogrcurvepolygon_polygonize
+        distance3D = xform1 c_ogrcurvepolygon_distance3d
+
+instance () => IDeletable (OGRCurvePolygon) where
+        delete = xform0 c_ogrcurvepolygon_delete
diff --git a/src/GDAL/OGRCurvePolygon/Interface.hs b/src/GDAL/OGRCurvePolygon/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurvePolygon/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRCurvePolygon.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRCurvePolygon.RawType
+import GDAL.OGRSurface.Interface
+
+class (IOGRSurface a) => IOGRCurvePolygon a where
+
+upcastOGRCurvePolygon ::
+                      forall a . (FPtr a, IOGRCurvePolygon a) => a -> OGRCurvePolygon
+upcastOGRCurvePolygon h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRCurvePolygon = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRCurvePolygon ::
+                        forall a . (FPtr a, IOGRCurvePolygon a) => OGRCurvePolygon -> a
+downcastOGRCurvePolygon h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRCurvePolygon/RawType.hs b/src/GDAL/OGRCurvePolygon/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRCurvePolygon/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRCurvePolygon.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRCurvePolygon
+
+newtype OGRCurvePolygon = OGRCurvePolygon (Ptr RawOGRCurvePolygon)
+                            deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRCurvePolygon) where
+        type Raw OGRCurvePolygon = RawOGRCurvePolygon
+        get_fptr (OGRCurvePolygon ptr) = ptr
+        cast_fptr_to_obj = OGRCurvePolygon
diff --git a/src/GDAL/OGREnvelope.hs b/src/GDAL/OGREnvelope.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGREnvelope.hs
@@ -0,0 +1,7 @@
+module GDAL.OGREnvelope
+       (OGREnvelope(..), IOGREnvelope, upcastOGREnvelope,
+        downcastOGREnvelope, newOGREnvelope)
+       where
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Interface
+import GDAL.OGREnvelope.Implementation
diff --git a/src/GDAL/OGREnvelope/Cast.hs b/src/GDAL/OGREnvelope/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGREnvelope/Cast.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGREnvelope.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Interface
+
+instance (IOGREnvelope a, FPtr a) =>
+         Castable (a) (Ptr RawOGREnvelope)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGREnvelope) (Ptr RawOGREnvelope) where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGREnvelope/FFI.hsc b/src/GDAL/OGREnvelope/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGREnvelope/FFI.hsc
@@ -0,0 +1,40 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGREnvelope.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.RawType
+
+foreign import ccall interruptible
+               "HGDALOGREnvelope.h OGREnvelope_delete" c_ogrenvelope_delete ::
+               Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGREnvelope.h OGREnvelope_newOGREnvelope"
+               c_ogrenvelope_newogrenvelope :: IO (Ptr RawOGREnvelope)
+
+foreign import ccall interruptible "OGREnvelope_MinX_get"
+               c_ogrenvelope_minx_get :: Ptr RawOGREnvelope -> IO CDouble
+
+foreign import ccall interruptible "OGREnvelope_MinX_set"
+               c_ogrenvelope_minx_set :: Ptr RawOGREnvelope -> CDouble -> IO ()
+
+foreign import ccall interruptible "OGREnvelope_MaxX_get"
+               c_ogrenvelope_maxx_get :: Ptr RawOGREnvelope -> IO CDouble
+
+foreign import ccall interruptible "OGREnvelope_MaxX_set"
+               c_ogrenvelope_maxx_set :: Ptr RawOGREnvelope -> CDouble -> IO ()
+
+foreign import ccall interruptible "OGREnvelope_MinY_get"
+               c_ogrenvelope_miny_get :: Ptr RawOGREnvelope -> IO CDouble
+
+foreign import ccall interruptible "OGREnvelope_MinY_set"
+               c_ogrenvelope_miny_set :: Ptr RawOGREnvelope -> CDouble -> IO ()
+
+foreign import ccall interruptible "OGREnvelope_MaxY_get"
+               c_ogrenvelope_maxy_get :: Ptr RawOGREnvelope -> IO CDouble
+
+foreign import ccall interruptible "OGREnvelope_MaxY_set"
+               c_ogrenvelope_maxy_set :: Ptr RawOGREnvelope -> CDouble -> IO ()
diff --git a/src/GDAL/OGREnvelope/Implementation.hs b/src/GDAL/OGREnvelope/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGREnvelope/Implementation.hs
@@ -0,0 +1,58 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGREnvelope.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.FFI
+import GDAL.OGREnvelope.Interface
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGREnvelope (OGREnvelope) where
+
+instance () => IDeletable (OGREnvelope) where
+        delete = xform0 c_ogrenvelope_delete
+
+newOGREnvelope :: () => IO OGREnvelope
+newOGREnvelope = xformnull c_ogrenvelope_newogrenvelope
+
+oGREnvelope_MinX_get :: () => OGREnvelope -> IO CDouble
+oGREnvelope_MinX_get = xform0 c_ogrenvelope_minx_get
+
+oGREnvelope_MinX_set :: () => OGREnvelope -> CDouble -> IO ()
+oGREnvelope_MinX_set = xform1 c_ogrenvelope_minx_set
+
+oGREnvelope_MaxX_get :: () => OGREnvelope -> IO CDouble
+oGREnvelope_MaxX_get = xform0 c_ogrenvelope_maxx_get
+
+oGREnvelope_MaxX_set :: () => OGREnvelope -> CDouble -> IO ()
+oGREnvelope_MaxX_set = xform1 c_ogrenvelope_maxx_set
+
+oGREnvelope_MinY_get :: () => OGREnvelope -> IO CDouble
+oGREnvelope_MinY_get = xform0 c_ogrenvelope_miny_get
+
+oGREnvelope_MinY_set :: () => OGREnvelope -> CDouble -> IO ()
+oGREnvelope_MinY_set = xform1 c_ogrenvelope_miny_set
+
+oGREnvelope_MaxY_get :: () => OGREnvelope -> IO CDouble
+oGREnvelope_MaxY_get = xform0 c_ogrenvelope_maxy_get
+
+oGREnvelope_MaxY_set :: () => OGREnvelope -> CDouble -> IO ()
+oGREnvelope_MaxY_set = xform1 c_ogrenvelope_maxy_set
diff --git a/src/GDAL/OGREnvelope/Interface.hs b/src/GDAL/OGREnvelope/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGREnvelope/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGREnvelope.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGREnvelope.RawType
+import STD.Deletable.Interface
+
+class (IDeletable a) => IOGREnvelope a where
+
+upcastOGREnvelope ::
+                  forall a . (FPtr a, IOGREnvelope a) => a -> OGREnvelope
+upcastOGREnvelope h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGREnvelope = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGREnvelope ::
+                    forall a . (FPtr a, IOGREnvelope a) => OGREnvelope -> a
+downcastOGREnvelope h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGREnvelope/RawType.hs b/src/GDAL/OGREnvelope/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGREnvelope/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGREnvelope.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGREnvelope
+
+newtype OGREnvelope = OGREnvelope (Ptr RawOGREnvelope)
+                        deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGREnvelope) where
+        type Raw OGREnvelope = RawOGREnvelope
+        get_fptr (OGREnvelope ptr) = ptr
+        cast_fptr_to_obj = OGREnvelope
diff --git a/src/GDAL/OGRFeature.hs b/src/GDAL/OGRFeature.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeature.hs
@@ -0,0 +1,9 @@
+module GDAL.OGRFeature
+       (OGRFeature(..), IOGRFeature, upcastOGRFeature, downcastOGRFeature,
+        oGRFeature_GetFID, oGRFeature_GetFieldCount,
+        oGRFeature_GetFieldAsInteger, oGRFeature_GetFieldAsInteger64,
+        oGRFeature_GetFieldAsString, oGRFeature_GetGeometryRef)
+       where
+import GDAL.OGRFeature.RawType
+import GDAL.OGRFeature.Interface
+import GDAL.OGRFeature.Implementation
diff --git a/src/GDAL/OGRFeature/Cast.hs b/src/GDAL/OGRFeature/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeature/Cast.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRFeature.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRFeature.RawType
+import GDAL.OGRFeature.Interface
+
+instance (IOGRFeature a, FPtr a) =>
+         Castable (a) (Ptr RawOGRFeature)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRFeature) (Ptr RawOGRFeature) where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRFeature/FFI.hsc b/src/GDAL/OGRFeature/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeature/FFI.hsc
@@ -0,0 +1,42 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRFeature.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRFeature.RawType
+import GDAL.OGRFeature.RawType
+import GDAL.OGRGeometry.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRFeature.h OGRFeature_delete" c_ogrfeature_delete ::
+               Ptr RawOGRFeature -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRFeature.h OGRFeature_oGRFeature_GetFID"
+               c_ogrfeature_ogrfeature_getfid :: Ptr RawOGRFeature -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRFeature.h OGRFeature_oGRFeature_GetFieldCount"
+               c_ogrfeature_ogrfeature_getfieldcount ::
+               Ptr RawOGRFeature -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRFeature.h OGRFeature_oGRFeature_GetFieldAsInteger"
+               c_ogrfeature_ogrfeature_getfieldasinteger ::
+               Ptr RawOGRFeature -> CInt -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRFeature.h OGRFeature_oGRFeature_GetFieldAsInteger64"
+               c_ogrfeature_ogrfeature_getfieldasinteger64 ::
+               Ptr RawOGRFeature -> CInt -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRFeature.h OGRFeature_oGRFeature_GetFieldAsString"
+               c_ogrfeature_ogrfeature_getfieldasstring ::
+               Ptr RawOGRFeature -> CInt -> IO CString
+
+foreign import ccall interruptible
+               "HGDALOGRFeature.h OGRFeature_oGRFeature_GetGeometryRef"
+               c_ogrfeature_ogrfeature_getgeometryref ::
+               Ptr RawOGRFeature -> IO (Ptr RawOGRGeometry)
diff --git a/src/GDAL/OGRFeature/Implementation.hs b/src/GDAL/OGRFeature/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeature/Implementation.hs
@@ -0,0 +1,59 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRFeature.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRFeature.RawType
+import GDAL.OGRFeature.FFI
+import GDAL.OGRFeature.Interface
+import GDAL.OGRFeature.Cast
+import GDAL.OGRFeature.RawType
+import GDAL.OGRFeature.Cast
+import GDAL.OGRFeature.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRFeature (OGRFeature) where
+
+instance () => IDeletable (OGRFeature) where
+        delete = xform0 c_ogrfeature_delete
+
+oGRFeature_GetFID :: () => OGRFeature -> IO CInt
+oGRFeature_GetFID = xform0 c_ogrfeature_ogrfeature_getfid
+
+oGRFeature_GetFieldCount :: () => OGRFeature -> IO CInt
+oGRFeature_GetFieldCount
+  = xform0 c_ogrfeature_ogrfeature_getfieldcount
+
+oGRFeature_GetFieldAsInteger :: () => OGRFeature -> CInt -> IO CInt
+oGRFeature_GetFieldAsInteger
+  = xform1 c_ogrfeature_ogrfeature_getfieldasinteger
+
+oGRFeature_GetFieldAsInteger64 ::
+                                 () => OGRFeature -> CInt -> IO CInt
+oGRFeature_GetFieldAsInteger64
+  = xform1 c_ogrfeature_ogrfeature_getfieldasinteger64
+
+oGRFeature_GetFieldAsString ::
+                              () => OGRFeature -> CInt -> IO CString
+oGRFeature_GetFieldAsString
+  = xform1 c_ogrfeature_ogrfeature_getfieldasstring
+
+oGRFeature_GetGeometryRef :: () => OGRFeature -> IO OGRGeometry
+oGRFeature_GetGeometryRef
+  = xform0 c_ogrfeature_ogrfeature_getgeometryref
diff --git a/src/GDAL/OGRFeature/Interface.hs b/src/GDAL/OGRFeature/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeature/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRFeature.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRFeature.RawType
+import STD.Deletable.Interface
+
+class (IDeletable a) => IOGRFeature a where
+
+upcastOGRFeature ::
+                 forall a . (FPtr a, IOGRFeature a) => a -> OGRFeature
+upcastOGRFeature h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRFeature = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRFeature ::
+                   forall a . (FPtr a, IOGRFeature a) => OGRFeature -> a
+downcastOGRFeature h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRFeature/RawType.hs b/src/GDAL/OGRFeature/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeature/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRFeature.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRFeature
+
+newtype OGRFeature = OGRFeature (Ptr RawOGRFeature)
+                       deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRFeature) where
+        type Raw OGRFeature = RawOGRFeature
+        get_fptr (OGRFeature ptr) = ptr
+        cast_fptr_to_obj = OGRFeature
diff --git a/src/GDAL/OGRFeatureDefn.hs b/src/GDAL/OGRFeatureDefn.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeatureDefn.hs
@@ -0,0 +1,7 @@
+module GDAL.OGRFeatureDefn
+       (OGRFeatureDefn(..), IOGRFeatureDefn(..), upcastOGRFeatureDefn,
+        downcastOGRFeatureDefn)
+       where
+import GDAL.OGRFeatureDefn.RawType
+import GDAL.OGRFeatureDefn.Interface
+import GDAL.OGRFeatureDefn.Implementation
diff --git a/src/GDAL/OGRFeatureDefn/Cast.hs b/src/GDAL/OGRFeatureDefn/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeatureDefn/Cast.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRFeatureDefn.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRFeatureDefn.RawType
+import GDAL.OGRFeatureDefn.Interface
+
+instance (IOGRFeatureDefn a, FPtr a) =>
+         Castable (a) (Ptr RawOGRFeatureDefn)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRFeatureDefn) (Ptr RawOGRFeatureDefn)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRFeatureDefn/FFI.hsc b/src/GDAL/OGRFeatureDefn/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeatureDefn/FFI.hsc
@@ -0,0 +1,27 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRFeatureDefn.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRFeatureDefn.RawType
+import GDAL.OGRFeatureDefn.RawType
+import GDAL.OGRFieldDefn.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRFeatureDefn.h OGRFeatureDefn_delete"
+               c_ogrfeaturedefn_delete :: Ptr RawOGRFeatureDefn -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRFeatureDefn.h OGRFeatureDefn_GetFieldCount"
+               c_ogrfeaturedefn_getfieldcount :: Ptr RawOGRFeatureDefn -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRFeatureDefn.h OGRFeatureDefn_GetFieldDefn"
+               c_ogrfeaturedefn_getfielddefn ::
+               Ptr RawOGRFeatureDefn -> CInt -> IO (Ptr RawOGRFieldDefn)
+
+foreign import ccall interruptible
+               "HGDALOGRFeatureDefn.h OGRFeatureDefn_GetGeomFieldCount"
+               c_ogrfeaturedefn_getgeomfieldcount ::
+               Ptr RawOGRFeatureDefn -> IO CInt
diff --git a/src/GDAL/OGRFeatureDefn/Implementation.hs b/src/GDAL/OGRFeatureDefn/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeatureDefn/Implementation.hs
@@ -0,0 +1,37 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRFeatureDefn.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRFeatureDefn.RawType
+import GDAL.OGRFeatureDefn.FFI
+import GDAL.OGRFeatureDefn.Interface
+import GDAL.OGRFeatureDefn.Cast
+import GDAL.OGRFeatureDefn.RawType
+import GDAL.OGRFeatureDefn.Cast
+import GDAL.OGRFeatureDefn.Interface
+import GDAL.OGRFieldDefn.RawType
+import GDAL.OGRFieldDefn.Cast
+import GDAL.OGRFieldDefn.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRFeatureDefn (OGRFeatureDefn) where
+        getFieldCount = xform0 c_ogrfeaturedefn_getfieldcount
+        getFieldDefn = xform1 c_ogrfeaturedefn_getfielddefn
+        getGeomFieldCount = xform0 c_ogrfeaturedefn_getgeomfieldcount
+
+instance () => IDeletable (OGRFeatureDefn) where
+        delete = xform0 c_ogrfeaturedefn_delete
diff --git a/src/GDAL/OGRFeatureDefn/Interface.hs b/src/GDAL/OGRFeatureDefn/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeatureDefn/Interface.hs
@@ -0,0 +1,34 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRFeatureDefn.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRFeatureDefn.RawType
+import GDAL.OGRFieldDefn.RawType
+import STD.Deletable.Interface
+
+class (IDeletable a) => IOGRFeatureDefn a where
+        getFieldCount :: () => a -> IO CInt
+        
+        getFieldDefn :: () => a -> CInt -> IO OGRFieldDefn
+        
+        getGeomFieldCount :: () => a -> IO CInt
+
+upcastOGRFeatureDefn ::
+                     forall a . (FPtr a, IOGRFeatureDefn a) => a -> OGRFeatureDefn
+upcastOGRFeatureDefn h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRFeatureDefn = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRFeatureDefn ::
+                       forall a . (FPtr a, IOGRFeatureDefn a) => OGRFeatureDefn -> a
+downcastOGRFeatureDefn h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRFeatureDefn/RawType.hs b/src/GDAL/OGRFeatureDefn/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFeatureDefn/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRFeatureDefn.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRFeatureDefn
+
+newtype OGRFeatureDefn = OGRFeatureDefn (Ptr RawOGRFeatureDefn)
+                           deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRFeatureDefn) where
+        type Raw OGRFeatureDefn = RawOGRFeatureDefn
+        get_fptr (OGRFeatureDefn ptr) = ptr
+        cast_fptr_to_obj = OGRFeatureDefn
diff --git a/src/GDAL/OGRFieldDefn.hs b/src/GDAL/OGRFieldDefn.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFieldDefn.hs
@@ -0,0 +1,8 @@
+module GDAL.OGRFieldDefn
+       (OGRFieldDefn(..), IOGRFieldDefn, upcastOGRFieldDefn,
+        downcastOGRFieldDefn, oGRFieldDefn_GetNameRef,
+        oGRFieldDefn_GetType)
+       where
+import GDAL.OGRFieldDefn.RawType
+import GDAL.OGRFieldDefn.Interface
+import GDAL.OGRFieldDefn.Implementation
diff --git a/src/GDAL/OGRFieldDefn/Cast.hs b/src/GDAL/OGRFieldDefn/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFieldDefn/Cast.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRFieldDefn.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRFieldDefn.RawType
+import GDAL.OGRFieldDefn.Interface
+
+instance (IOGRFieldDefn a, FPtr a) =>
+         Castable (a) (Ptr RawOGRFieldDefn)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRFieldDefn) (Ptr RawOGRFieldDefn) where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRFieldDefn/FFI.hsc b/src/GDAL/OGRFieldDefn/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFieldDefn/FFI.hsc
@@ -0,0 +1,22 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRFieldDefn.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRFieldDefn.RawType
+import GDAL.OGRFieldDefn.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRFieldDefn.h OGRFieldDefn_delete" c_ogrfielddefn_delete ::
+               Ptr RawOGRFieldDefn -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRFieldDefn.h OGRFieldDefn_oGRFieldDefn_GetNameRef"
+               c_ogrfielddefn_ogrfielddefn_getnameref ::
+               Ptr RawOGRFieldDefn -> IO CString
+
+foreign import ccall interruptible
+               "HGDALOGRFieldDefn.h OGRFieldDefn_oGRFieldDefn_GetType"
+               c_ogrfielddefn_ogrfielddefn_gettype ::
+               Ptr RawOGRFieldDefn -> IO CUInt
diff --git a/src/GDAL/OGRFieldDefn/Implementation.hs b/src/GDAL/OGRFieldDefn/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFieldDefn/Implementation.hs
@@ -0,0 +1,38 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRFieldDefn.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRFieldDefn.RawType
+import GDAL.OGRFieldDefn.FFI
+import GDAL.OGRFieldDefn.Interface
+import GDAL.OGRFieldDefn.Cast
+import GDAL.OGRFieldDefn.RawType
+import GDAL.OGRFieldDefn.Cast
+import GDAL.OGRFieldDefn.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRFieldDefn (OGRFieldDefn) where
+
+instance () => IDeletable (OGRFieldDefn) where
+        delete = xform0 c_ogrfielddefn_delete
+
+oGRFieldDefn_GetNameRef :: () => OGRFieldDefn -> IO CString
+oGRFieldDefn_GetNameRef
+  = xform0 c_ogrfielddefn_ogrfielddefn_getnameref
+
+oGRFieldDefn_GetType :: () => OGRFieldDefn -> IO CUInt
+oGRFieldDefn_GetType = xform0 c_ogrfielddefn_ogrfielddefn_gettype
diff --git a/src/GDAL/OGRFieldDefn/Interface.hs b/src/GDAL/OGRFieldDefn/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFieldDefn/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRFieldDefn.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRFieldDefn.RawType
+import STD.Deletable.Interface
+
+class (IDeletable a) => IOGRFieldDefn a where
+
+upcastOGRFieldDefn ::
+                   forall a . (FPtr a, IOGRFieldDefn a) => a -> OGRFieldDefn
+upcastOGRFieldDefn h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRFieldDefn = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRFieldDefn ::
+                     forall a . (FPtr a, IOGRFieldDefn a) => OGRFieldDefn -> a
+downcastOGRFieldDefn h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRFieldDefn/RawType.hs b/src/GDAL/OGRFieldDefn/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRFieldDefn/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRFieldDefn.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRFieldDefn
+
+newtype OGRFieldDefn = OGRFieldDefn (Ptr RawOGRFieldDefn)
+                         deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRFieldDefn) where
+        type Raw OGRFieldDefn = RawOGRFieldDefn
+        get_fptr (OGRFieldDefn ptr) = ptr
+        cast_fptr_to_obj = OGRFieldDefn
diff --git a/src/GDAL/OGRGeometry.hs b/src/GDAL/OGRGeometry.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometry.hs
@@ -0,0 +1,8 @@
+module GDAL.OGRGeometry
+       (OGRGeometry(..), IOGRGeometry(..), upcastOGRGeometry,
+        downcastOGRGeometry, oGRGeometry_SimplifyPreserveTopology,
+        oGRGeometry_toPolygon, oGRGeometry_toMultiPolygon)
+       where
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Interface
+import GDAL.OGRGeometry.Implementation
diff --git a/src/GDAL/OGRGeometry/Cast.hs b/src/GDAL/OGRGeometry/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometry/Cast.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRGeometry.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Interface
+
+instance (IOGRGeometry a, FPtr a) =>
+         Castable (a) (Ptr RawOGRGeometry)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRGeometry) (Ptr RawOGRGeometry) where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRGeometry/FFI.hsc b/src/GDAL/OGRGeometry/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometry/FFI.hsc
@@ -0,0 +1,137 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRGeometry.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGREnvelope.RawType
+import GDAL.OGRPoint.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_delete" c_ogrgeometry_delete ::
+               Ptr RawOGRGeometry -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_getGeometryType"
+               c_ogrgeometry_getgeometrytype :: Ptr RawOGRGeometry -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_getEnvelope"
+               c_ogrgeometry_getenvelope ::
+               Ptr RawOGRGeometry -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Intersects"
+               c_ogrgeometry_intersects ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Equals" c_ogrgeometry_equals ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Disjoint" c_ogrgeometry_disjoint ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Touches" c_ogrgeometry_touches ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Crosses" c_ogrgeometry_crosses ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Within" c_ogrgeometry_within ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Contains" c_ogrgeometry_contains ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Overlaps" c_ogrgeometry_overlaps ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Boundary" c_ogrgeometry_boundary ::
+               Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Distance" c_ogrgeometry_distance ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_ConvexHull"
+               c_ogrgeometry_convexhull ::
+               Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Buffer" c_ogrgeometry_buffer ::
+               Ptr RawOGRGeometry -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Intersection"
+               c_ogrgeometry_intersection ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Union" c_ogrgeometry_union ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_UnionCascaded"
+               c_ogrgeometry_unioncascaded ::
+               Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Difference"
+               c_ogrgeometry_difference ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_SymDifference"
+               c_ogrgeometry_symdifference ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Centroid" c_ogrgeometry_centroid ::
+               Ptr RawOGRGeometry -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Simplify" c_ogrgeometry_simplify ::
+               Ptr RawOGRGeometry -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_oGRGeometry_SimplifyPreserveTopology"
+               c_ogrgeometry_ogrgeometry_simplifypreservetopology ::
+               Ptr RawOGRGeometry -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_DelaunayTriangulation"
+               c_ogrgeometry_delaunaytriangulation ::
+               Ptr RawOGRGeometry -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Polygonize"
+               c_ogrgeometry_polygonize ::
+               Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_Distance3D"
+               c_ogrgeometry_distance3d ::
+               Ptr RawOGRGeometry -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_oGRGeometry_toPolygon"
+               c_ogrgeometry_ogrgeometry_topolygon ::
+               Ptr RawOGRGeometry -> IO (Ptr RawOGRPolygon)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometry.h OGRGeometry_oGRGeometry_toMultiPolygon"
+               c_ogrgeometry_ogrgeometry_tomultipolygon ::
+               Ptr RawOGRGeometry -> IO (Ptr RawOGRMultiPolygon)
diff --git a/src/GDAL/OGRGeometry/Implementation.hs b/src/GDAL/OGRGeometry/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometry/Implementation.hs
@@ -0,0 +1,80 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRGeometry.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.FFI
+import GDAL.OGRGeometry.Interface
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRGeometry (OGRGeometry) where
+        getGeometryType = xform0 c_ogrgeometry_getgeometrytype
+        getEnvelope = xform1 c_ogrgeometry_getenvelope
+        intersects = xform1 c_ogrgeometry_intersects
+        equals = xform1 c_ogrgeometry_equals
+        disjoint = xform1 c_ogrgeometry_disjoint
+        touches = xform1 c_ogrgeometry_touches
+        crosses = xform1 c_ogrgeometry_crosses
+        within = xform1 c_ogrgeometry_within
+        contains = xform1 c_ogrgeometry_contains
+        overlaps = xform1 c_ogrgeometry_overlaps
+        boundary = xform0 c_ogrgeometry_boundary
+        distance = xform1 c_ogrgeometry_distance
+        convexHull = xform0 c_ogrgeometry_convexhull
+        buffer = xform2 c_ogrgeometry_buffer
+        intersection = xform1 c_ogrgeometry_intersection
+        union = xform1 c_ogrgeometry_union
+        unionCascaded = xform0 c_ogrgeometry_unioncascaded
+        difference = xform1 c_ogrgeometry_difference
+        symDifference = xform1 c_ogrgeometry_symdifference
+        centroid = xform1 c_ogrgeometry_centroid
+        simplify = xform1 c_ogrgeometry_simplify
+        delaunayTriangulation = xform2 c_ogrgeometry_delaunaytriangulation
+        polygonize = xform0 c_ogrgeometry_polygonize
+        distance3D = xform1 c_ogrgeometry_distance3d
+
+instance () => IDeletable (OGRGeometry) where
+        delete = xform0 c_ogrgeometry_delete
+
+oGRGeometry_SimplifyPreserveTopology ::
+                                       () => OGRGeometry -> CDouble -> IO OGRGeometry
+oGRGeometry_SimplifyPreserveTopology
+  = xform1 c_ogrgeometry_ogrgeometry_simplifypreservetopology
+
+oGRGeometry_toPolygon :: () => OGRGeometry -> IO OGRPolygon
+oGRGeometry_toPolygon = xform0 c_ogrgeometry_ogrgeometry_topolygon
+
+oGRGeometry_toMultiPolygon ::
+                             () => OGRGeometry -> IO OGRMultiPolygon
+oGRGeometry_toMultiPolygon
+  = xform0 c_ogrgeometry_ogrgeometry_tomultipolygon
diff --git a/src/GDAL/OGRGeometry/Interface.hs b/src/GDAL/OGRGeometry/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometry/Interface.hs
@@ -0,0 +1,81 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRGeometry.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRGeometry.RawType
+import STD.Deletable.Interface
+import GDAL.OGREnvelope.Interface
+import {-# SOURCE #-} GDAL.OGRPoint.Interface
+
+class (IDeletable a) => IOGRGeometry a where
+        getGeometryType :: () => a -> IO CUInt
+        
+        getEnvelope :: (IOGREnvelope c0, FPtr c0) => a -> c0 -> IO ()
+        
+        intersects :: (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO CBool
+        
+        equals :: (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO CBool
+        
+        disjoint :: (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO CBool
+        
+        touches :: (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO CBool
+        
+        crosses :: (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO CBool
+        
+        within :: (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO CBool
+        
+        contains :: (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO CBool
+        
+        overlaps :: (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO CBool
+        
+        boundary :: () => a -> IO OGRGeometry
+        
+        distance :: (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO CDouble
+        
+        convexHull :: () => a -> IO OGRGeometry
+        
+        buffer :: () => a -> CDouble -> CInt -> IO OGRGeometry
+        
+        intersection ::
+                       (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO OGRGeometry
+        
+        union :: (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO OGRGeometry
+        
+        unionCascaded :: () => a -> IO OGRGeometry
+        
+        difference ::
+                     (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO OGRGeometry
+        
+        symDifference ::
+                        (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO OGRGeometry
+        
+        centroid :: (IOGRPoint c0, FPtr c0) => a -> c0 -> IO CInt
+        
+        simplify :: () => a -> CDouble -> IO OGRGeometry
+        
+        delaunayTriangulation ::
+                                () => a -> CDouble -> CInt -> IO OGRGeometry
+        
+        polygonize :: () => a -> IO OGRGeometry
+        
+        distance3D :: (IOGRGeometry c0, FPtr c0) => a -> c0 -> IO CDouble
+
+upcastOGRGeometry ::
+                  forall a . (FPtr a, IOGRGeometry a) => a -> OGRGeometry
+upcastOGRGeometry h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRGeometry = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRGeometry ::
+                    forall a . (FPtr a, IOGRGeometry a) => OGRGeometry -> a
+downcastOGRGeometry h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRGeometry/RawType.hs b/src/GDAL/OGRGeometry/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometry/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRGeometry.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRGeometry
+
+newtype OGRGeometry = OGRGeometry (Ptr RawOGRGeometry)
+                        deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRGeometry) where
+        type Raw OGRGeometry = RawOGRGeometry
+        get_fptr (OGRGeometry ptr) = ptr
+        cast_fptr_to_obj = OGRGeometry
diff --git a/src/GDAL/OGRGeometryCollection.hs b/src/GDAL/OGRGeometryCollection.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometryCollection.hs
@@ -0,0 +1,9 @@
+module GDAL.OGRGeometryCollection
+       (OGRGeometryCollection(..), IOGRGeometryCollection,
+        upcastOGRGeometryCollection, downcastOGRGeometryCollection,
+        oGRGeometryCollection_getNumGeometries,
+        oGRGeometryCollection_getGeometryRef)
+       where
+import GDAL.OGRGeometryCollection.RawType
+import GDAL.OGRGeometryCollection.Interface
+import GDAL.OGRGeometryCollection.Implementation
diff --git a/src/GDAL/OGRGeometryCollection/Cast.hs b/src/GDAL/OGRGeometryCollection/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometryCollection/Cast.hs
@@ -0,0 +1,21 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRGeometryCollection.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRGeometryCollection.RawType
+import GDAL.OGRGeometryCollection.Interface
+
+instance (IOGRGeometryCollection a, FPtr a) =>
+         Castable (a) (Ptr RawOGRGeometryCollection)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () =>
+         Castable (OGRGeometryCollection) (Ptr RawOGRGeometryCollection)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRGeometryCollection/FFI.hsc b/src/GDAL/OGRGeometryCollection/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometryCollection/FFI.hsc
@@ -0,0 +1,154 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRGeometryCollection.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRGeometryCollection.RawType
+import GDAL.OGRGeometryCollection.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGREnvelope.RawType
+import GDAL.OGRPoint.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_getGeometryType"
+               c_ogrgeometrycollection_getgeometrytype ::
+               Ptr RawOGRGeometryCollection -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_getEnvelope"
+               c_ogrgeometrycollection_getenvelope ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Intersects"
+               c_ogrgeometrycollection_intersects ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Equals"
+               c_ogrgeometrycollection_equals ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Disjoint"
+               c_ogrgeometrycollection_disjoint ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Touches"
+               c_ogrgeometrycollection_touches ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Crosses"
+               c_ogrgeometrycollection_crosses ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Within"
+               c_ogrgeometrycollection_within ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Contains"
+               c_ogrgeometrycollection_contains ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Overlaps"
+               c_ogrgeometrycollection_overlaps ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Boundary"
+               c_ogrgeometrycollection_boundary ::
+               Ptr RawOGRGeometryCollection -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Distance"
+               c_ogrgeometrycollection_distance ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_ConvexHull"
+               c_ogrgeometrycollection_convexhull ::
+               Ptr RawOGRGeometryCollection -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Buffer"
+               c_ogrgeometrycollection_buffer ::
+               Ptr RawOGRGeometryCollection ->
+                 CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Intersection"
+               c_ogrgeometrycollection_intersection ::
+               Ptr RawOGRGeometryCollection ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Union"
+               c_ogrgeometrycollection_union ::
+               Ptr RawOGRGeometryCollection ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_UnionCascaded"
+               c_ogrgeometrycollection_unioncascaded ::
+               Ptr RawOGRGeometryCollection -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Difference"
+               c_ogrgeometrycollection_difference ::
+               Ptr RawOGRGeometryCollection ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_SymDifference"
+               c_ogrgeometrycollection_symdifference ::
+               Ptr RawOGRGeometryCollection ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Centroid"
+               c_ogrgeometrycollection_centroid ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Simplify"
+               c_ogrgeometrycollection_simplify ::
+               Ptr RawOGRGeometryCollection -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_DelaunayTriangulation"
+               c_ogrgeometrycollection_delaunaytriangulation ::
+               Ptr RawOGRGeometryCollection ->
+                 CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Polygonize"
+               c_ogrgeometrycollection_polygonize ::
+               Ptr RawOGRGeometryCollection -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_Distance3D"
+               c_ogrgeometrycollection_distance3d ::
+               Ptr RawOGRGeometryCollection -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_delete"
+               c_ogrgeometrycollection_delete ::
+               Ptr RawOGRGeometryCollection -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_oGRGeometryCollection_getNumGeometries"
+               c_ogrgeometrycollection_ogrgeometrycollection_getnumgeometries ::
+               Ptr RawOGRGeometryCollection -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRGeometryCollection.h OGRGeometryCollection_oGRGeometryCollection_getGeometryRef"
+               c_ogrgeometrycollection_ogrgeometrycollection_getgeometryref ::
+               Ptr RawOGRGeometryCollection -> CInt -> IO (Ptr RawOGRGeometry)
diff --git a/src/GDAL/OGRGeometryCollection/Implementation.hs b/src/GDAL/OGRGeometryCollection/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometryCollection/Implementation.hs
@@ -0,0 +1,85 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRGeometryCollection.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRGeometryCollection.RawType
+import GDAL.OGRGeometryCollection.FFI
+import GDAL.OGRGeometryCollection.Interface
+import GDAL.OGRGeometryCollection.Cast
+import GDAL.OGRGeometryCollection.RawType
+import GDAL.OGRGeometryCollection.Cast
+import GDAL.OGRGeometryCollection.Interface
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRGeometryCollection (OGRGeometryCollection) where
+
+instance () => IOGRGeometry (OGRGeometryCollection) where
+        getGeometryType = xform0 c_ogrgeometrycollection_getgeometrytype
+        getEnvelope = xform1 c_ogrgeometrycollection_getenvelope
+        intersects = xform1 c_ogrgeometrycollection_intersects
+        equals = xform1 c_ogrgeometrycollection_equals
+        disjoint = xform1 c_ogrgeometrycollection_disjoint
+        touches = xform1 c_ogrgeometrycollection_touches
+        crosses = xform1 c_ogrgeometrycollection_crosses
+        within = xform1 c_ogrgeometrycollection_within
+        contains = xform1 c_ogrgeometrycollection_contains
+        overlaps = xform1 c_ogrgeometrycollection_overlaps
+        boundary = xform0 c_ogrgeometrycollection_boundary
+        distance = xform1 c_ogrgeometrycollection_distance
+        convexHull = xform0 c_ogrgeometrycollection_convexhull
+        buffer = xform2 c_ogrgeometrycollection_buffer
+        intersection = xform1 c_ogrgeometrycollection_intersection
+        union = xform1 c_ogrgeometrycollection_union
+        unionCascaded = xform0 c_ogrgeometrycollection_unioncascaded
+        difference = xform1 c_ogrgeometrycollection_difference
+        symDifference = xform1 c_ogrgeometrycollection_symdifference
+        centroid = xform1 c_ogrgeometrycollection_centroid
+        simplify = xform1 c_ogrgeometrycollection_simplify
+        delaunayTriangulation
+          = xform2 c_ogrgeometrycollection_delaunaytriangulation
+        polygonize = xform0 c_ogrgeometrycollection_polygonize
+        distance3D = xform1 c_ogrgeometrycollection_distance3d
+
+instance () => IDeletable (OGRGeometryCollection) where
+        delete = xform0 c_ogrgeometrycollection_delete
+
+oGRGeometryCollection_getNumGeometries ::
+                                         () => OGRGeometryCollection -> IO CInt
+oGRGeometryCollection_getNumGeometries
+  = xform0
+      c_ogrgeometrycollection_ogrgeometrycollection_getnumgeometries
+
+oGRGeometryCollection_getGeometryRef ::
+                                       () => OGRGeometryCollection -> CInt -> IO OGRGeometry
+oGRGeometryCollection_getGeometryRef
+  = xform1
+      c_ogrgeometrycollection_ogrgeometrycollection_getgeometryref
diff --git a/src/GDAL/OGRGeometryCollection/Interface.hs b/src/GDAL/OGRGeometryCollection/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometryCollection/Interface.hs
@@ -0,0 +1,30 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRGeometryCollection.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRGeometryCollection.RawType
+import GDAL.OGRGeometry.Interface
+
+class (IOGRGeometry a) => IOGRGeometryCollection a where
+
+upcastOGRGeometryCollection ::
+                            forall a . (FPtr a, IOGRGeometryCollection a) =>
+                              a -> OGRGeometryCollection
+upcastOGRGeometryCollection h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRGeometryCollection = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRGeometryCollection ::
+                              forall a . (FPtr a, IOGRGeometryCollection a) =>
+                                OGRGeometryCollection -> a
+downcastOGRGeometryCollection h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRGeometryCollection/RawType.hs b/src/GDAL/OGRGeometryCollection/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRGeometryCollection/RawType.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRGeometryCollection.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRGeometryCollection
+
+newtype OGRGeometryCollection = OGRGeometryCollection (Ptr
+                                                         RawOGRGeometryCollection)
+                                  deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRGeometryCollection) where
+        type Raw OGRGeometryCollection = RawOGRGeometryCollection
+        get_fptr (OGRGeometryCollection ptr) = ptr
+        cast_fptr_to_obj = OGRGeometryCollection
diff --git a/src/GDAL/OGRLayer.hs b/src/GDAL/OGRLayer.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLayer.hs
@@ -0,0 +1,6 @@
+module GDAL.OGRLayer
+       (OGRLayer(..), IOGRLayer(..), upcastOGRLayer, downcastOGRLayer)
+       where
+import GDAL.OGRLayer.RawType
+import GDAL.OGRLayer.Interface
+import GDAL.OGRLayer.Implementation
diff --git a/src/GDAL/OGRLayer/Cast.hs b/src/GDAL/OGRLayer/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLayer/Cast.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRLayer.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRLayer.RawType
+import GDAL.OGRLayer.Interface
+
+instance (IOGRLayer a, FPtr a) => Castable (a) (Ptr RawOGRLayer)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRLayer) (Ptr RawOGRLayer) where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRLayer/FFI.hsc b/src/GDAL/OGRLayer/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLayer/FFI.hsc
@@ -0,0 +1,34 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRLayer.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRLayer.RawType
+import GDAL.OGRLayer.RawType
+import GDAL.OGRFeature.RawType
+import GDAL.OGRFeatureDefn.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRLayer.h OGRLayer_delete" c_ogrlayer_delete ::
+               Ptr RawOGRLayer -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRLayer.h OGRLayer_GetFeature" c_ogrlayer_getfeature ::
+               Ptr RawOGRLayer -> CInt -> IO (Ptr RawOGRFeature)
+
+foreign import ccall interruptible
+               "HGDALOGRLayer.h OGRLayer_GetFeatureCount"
+               c_ogrlayer_getfeaturecount :: Ptr RawOGRLayer -> CInt -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRLayer.h OGRLayer_GetLayerDefn" c_ogrlayer_getlayerdefn ::
+               Ptr RawOGRLayer -> IO (Ptr RawOGRFeatureDefn)
+
+foreign import ccall interruptible
+               "HGDALOGRLayer.h OGRLayer_GetNextFeature" c_ogrlayer_getnextfeature
+               :: Ptr RawOGRLayer -> IO (Ptr RawOGRFeature)
+
+foreign import ccall interruptible
+               "HGDALOGRLayer.h OGRLayer_ResetReading" c_ogrlayer_resetreading ::
+               Ptr RawOGRLayer -> IO ()
diff --git a/src/GDAL/OGRLayer/Implementation.hs b/src/GDAL/OGRLayer/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLayer/Implementation.hs
@@ -0,0 +1,47 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRLayer.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRLayer.RawType
+import GDAL.OGRLayer.FFI
+import GDAL.OGRLayer.Interface
+import GDAL.OGRLayer.Cast
+import GDAL.OGRLayer.RawType
+import GDAL.OGRLayer.Cast
+import GDAL.OGRLayer.Interface
+import GDAL.OGRFeature.RawType
+import GDAL.OGRFeature.Cast
+import GDAL.OGRFeature.Interface
+import GDAL.OGRFeatureDefn.RawType
+import GDAL.OGRFeatureDefn.Cast
+import GDAL.OGRFeatureDefn.Interface
+import GDAL.GDALMajorObject.RawType
+import GDAL.GDALMajorObject.Cast
+import GDAL.GDALMajorObject.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRLayer (OGRLayer) where
+        getFeature = xform1 c_ogrlayer_getfeature
+        getFeatureCount = xform1 c_ogrlayer_getfeaturecount
+        getLayerDefn = xform0 c_ogrlayer_getlayerdefn
+        getNextFeature = xform0 c_ogrlayer_getnextfeature
+        resetReading = xform0 c_ogrlayer_resetreading
+
+instance () => IGDALMajorObject (OGRLayer) where
+
+instance () => IDeletable (OGRLayer) where
+        delete = xform0 c_ogrlayer_delete
diff --git a/src/GDAL/OGRLayer/Interface.hs b/src/GDAL/OGRLayer/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLayer/Interface.hs
@@ -0,0 +1,38 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRLayer.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRLayer.RawType
+import GDAL.OGRFeature.RawType
+import GDAL.OGRFeatureDefn.RawType
+import GDAL.GDALMajorObject.Interface
+
+class (IGDALMajorObject a) => IOGRLayer a where
+        getFeature :: () => a -> CInt -> IO OGRFeature
+        
+        getFeatureCount :: () => a -> CInt -> IO CInt
+        
+        getLayerDefn :: () => a -> IO OGRFeatureDefn
+        
+        getNextFeature :: () => a -> IO OGRFeature
+        
+        resetReading :: () => a -> IO ()
+
+upcastOGRLayer :: forall a . (FPtr a, IOGRLayer a) => a -> OGRLayer
+upcastOGRLayer h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRLayer = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRLayer ::
+                 forall a . (FPtr a, IOGRLayer a) => OGRLayer -> a
+downcastOGRLayer h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRLayer/RawType.hs b/src/GDAL/OGRLayer/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLayer/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRLayer.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRLayer
+
+newtype OGRLayer = OGRLayer (Ptr RawOGRLayer)
+                     deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRLayer) where
+        type Raw OGRLayer = RawOGRLayer
+        get_fptr (OGRLayer ptr) = ptr
+        cast_fptr_to_obj = OGRLayer
diff --git a/src/GDAL/OGRLineString.hs b/src/GDAL/OGRLineString.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLineString.hs
@@ -0,0 +1,7 @@
+module GDAL.OGRLineString
+       (OGRLineString(..), IOGRLineString, upcastOGRLineString,
+        downcastOGRLineString)
+       where
+import GDAL.OGRLineString.RawType
+import GDAL.OGRLineString.Interface
+import GDAL.OGRLineString.Implementation
diff --git a/src/GDAL/OGRLineString/Cast.hs b/src/GDAL/OGRLineString/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLineString/Cast.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRLineString.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRLineString.RawType
+import GDAL.OGRLineString.Interface
+
+instance (IOGRLineString a, FPtr a) =>
+         Castable (a) (Ptr RawOGRLineString)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRLineString) (Ptr RawOGRLineString)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRLineString/FFI.hsc b/src/GDAL/OGRLineString/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLineString/FFI.hsc
@@ -0,0 +1,147 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRLineString.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRLineString.RawType
+import GDAL.OGRLineString.RawType
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGREnvelope.RawType
+import GDAL.OGRPoint.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_getNumPoints"
+               c_ogrlinestring_getnumpoints :: Ptr RawOGRLineString -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_getPointIterator"
+               c_ogrlinestring_getpointiterator ::
+               Ptr RawOGRLineString -> IO (Ptr RawOGRPointIterator)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_getGeometryType"
+               c_ogrlinestring_getgeometrytype :: Ptr RawOGRLineString -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_getEnvelope"
+               c_ogrlinestring_getenvelope ::
+               Ptr RawOGRLineString -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Intersects"
+               c_ogrlinestring_intersects ::
+               Ptr RawOGRLineString -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Equals" c_ogrlinestring_equals
+               :: Ptr RawOGRLineString -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Disjoint"
+               c_ogrlinestring_disjoint ::
+               Ptr RawOGRLineString -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Touches"
+               c_ogrlinestring_touches ::
+               Ptr RawOGRLineString -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Crosses"
+               c_ogrlinestring_crosses ::
+               Ptr RawOGRLineString -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Within" c_ogrlinestring_within
+               :: Ptr RawOGRLineString -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Contains"
+               c_ogrlinestring_contains ::
+               Ptr RawOGRLineString -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Overlaps"
+               c_ogrlinestring_overlaps ::
+               Ptr RawOGRLineString -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Boundary"
+               c_ogrlinestring_boundary ::
+               Ptr RawOGRLineString -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Distance"
+               c_ogrlinestring_distance ::
+               Ptr RawOGRLineString -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_ConvexHull"
+               c_ogrlinestring_convexhull ::
+               Ptr RawOGRLineString -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Buffer" c_ogrlinestring_buffer
+               ::
+               Ptr RawOGRLineString -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Intersection"
+               c_ogrlinestring_intersection ::
+               Ptr RawOGRLineString ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Union" c_ogrlinestring_union ::
+               Ptr RawOGRLineString ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_UnionCascaded"
+               c_ogrlinestring_unioncascaded ::
+               Ptr RawOGRLineString -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Difference"
+               c_ogrlinestring_difference ::
+               Ptr RawOGRLineString ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_SymDifference"
+               c_ogrlinestring_symdifference ::
+               Ptr RawOGRLineString ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Centroid"
+               c_ogrlinestring_centroid ::
+               Ptr RawOGRLineString -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Simplify"
+               c_ogrlinestring_simplify ::
+               Ptr RawOGRLineString -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_DelaunayTriangulation"
+               c_ogrlinestring_delaunaytriangulation ::
+               Ptr RawOGRLineString -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Polygonize"
+               c_ogrlinestring_polygonize ::
+               Ptr RawOGRLineString -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_Distance3D"
+               c_ogrlinestring_distance3d ::
+               Ptr RawOGRLineString -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRLineString.h OGRLineString_delete" c_ogrlinestring_delete
+               :: Ptr RawOGRLineString -> IO ()
diff --git a/src/GDAL/OGRLineString/Implementation.hs b/src/GDAL/OGRLineString/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLineString/Implementation.hs
@@ -0,0 +1,88 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRLineString.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRLineString.RawType
+import GDAL.OGRLineString.FFI
+import GDAL.OGRLineString.Interface
+import GDAL.OGRLineString.Cast
+import GDAL.OGRLineString.RawType
+import GDAL.OGRLineString.Cast
+import GDAL.OGRLineString.Interface
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRPointIterator.Cast
+import GDAL.OGRPointIterator.Interface
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import GDAL.OGRSimpleCurve.RawType
+import GDAL.OGRSimpleCurve.Cast
+import GDAL.OGRSimpleCurve.Interface
+import GDAL.OGRCurve.RawType
+import GDAL.OGRCurve.Cast
+import GDAL.OGRCurve.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRLineString (OGRLineString) where
+
+instance () => IOGRSimpleCurve (OGRLineString) where
+
+instance () => IOGRCurve (OGRLineString) where
+        getNumPoints = xform0 c_ogrlinestring_getnumpoints
+        getPointIterator = xform0 c_ogrlinestring_getpointiterator
+
+instance () => IOGRGeometry (OGRLineString) where
+        getGeometryType = xform0 c_ogrlinestring_getgeometrytype
+        getEnvelope = xform1 c_ogrlinestring_getenvelope
+        intersects = xform1 c_ogrlinestring_intersects
+        equals = xform1 c_ogrlinestring_equals
+        disjoint = xform1 c_ogrlinestring_disjoint
+        touches = xform1 c_ogrlinestring_touches
+        crosses = xform1 c_ogrlinestring_crosses
+        within = xform1 c_ogrlinestring_within
+        contains = xform1 c_ogrlinestring_contains
+        overlaps = xform1 c_ogrlinestring_overlaps
+        boundary = xform0 c_ogrlinestring_boundary
+        distance = xform1 c_ogrlinestring_distance
+        convexHull = xform0 c_ogrlinestring_convexhull
+        buffer = xform2 c_ogrlinestring_buffer
+        intersection = xform1 c_ogrlinestring_intersection
+        union = xform1 c_ogrlinestring_union
+        unionCascaded = xform0 c_ogrlinestring_unioncascaded
+        difference = xform1 c_ogrlinestring_difference
+        symDifference = xform1 c_ogrlinestring_symdifference
+        centroid = xform1 c_ogrlinestring_centroid
+        simplify = xform1 c_ogrlinestring_simplify
+        delaunayTriangulation
+          = xform2 c_ogrlinestring_delaunaytriangulation
+        polygonize = xform0 c_ogrlinestring_polygonize
+        distance3D = xform1 c_ogrlinestring_distance3d
+
+instance () => IDeletable (OGRLineString) where
+        delete = xform0 c_ogrlinestring_delete
diff --git a/src/GDAL/OGRLineString/Interface.hs b/src/GDAL/OGRLineString/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLineString/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRLineString.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRLineString.RawType
+import GDAL.OGRSimpleCurve.Interface
+
+class (IOGRSimpleCurve a) => IOGRLineString a where
+
+upcastOGRLineString ::
+                    forall a . (FPtr a, IOGRLineString a) => a -> OGRLineString
+upcastOGRLineString h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRLineString = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRLineString ::
+                      forall a . (FPtr a, IOGRLineString a) => OGRLineString -> a
+downcastOGRLineString h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRLineString/RawType.hs b/src/GDAL/OGRLineString/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLineString/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRLineString.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRLineString
+
+newtype OGRLineString = OGRLineString (Ptr RawOGRLineString)
+                          deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRLineString) where
+        type Raw OGRLineString = RawOGRLineString
+        get_fptr (OGRLineString ptr) = ptr
+        cast_fptr_to_obj = OGRLineString
diff --git a/src/GDAL/OGRLinearRing.hs b/src/GDAL/OGRLinearRing.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLinearRing.hs
@@ -0,0 +1,7 @@
+module GDAL.OGRLinearRing
+       (OGRLinearRing(..), IOGRLinearRing, upcastOGRLinearRing,
+        downcastOGRLinearRing)
+       where
+import GDAL.OGRLinearRing.RawType
+import GDAL.OGRLinearRing.Interface
+import GDAL.OGRLinearRing.Implementation
diff --git a/src/GDAL/OGRLinearRing/Cast.hs b/src/GDAL/OGRLinearRing/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLinearRing/Cast.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRLinearRing.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRLinearRing.RawType
+import GDAL.OGRLinearRing.Interface
+
+instance (IOGRLinearRing a, FPtr a) =>
+         Castable (a) (Ptr RawOGRLinearRing)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRLinearRing) (Ptr RawOGRLinearRing)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRLinearRing/FFI.hsc b/src/GDAL/OGRLinearRing/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLinearRing/FFI.hsc
@@ -0,0 +1,147 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRLinearRing.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRLinearRing.RawType
+import GDAL.OGRLinearRing.RawType
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGREnvelope.RawType
+import GDAL.OGRPoint.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_getNumPoints"
+               c_ogrlinearring_getnumpoints :: Ptr RawOGRLinearRing -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_getPointIterator"
+               c_ogrlinearring_getpointiterator ::
+               Ptr RawOGRLinearRing -> IO (Ptr RawOGRPointIterator)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_getGeometryType"
+               c_ogrlinearring_getgeometrytype :: Ptr RawOGRLinearRing -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_getEnvelope"
+               c_ogrlinearring_getenvelope ::
+               Ptr RawOGRLinearRing -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Intersects"
+               c_ogrlinearring_intersects ::
+               Ptr RawOGRLinearRing -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Equals" c_ogrlinearring_equals
+               :: Ptr RawOGRLinearRing -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Disjoint"
+               c_ogrlinearring_disjoint ::
+               Ptr RawOGRLinearRing -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Touches"
+               c_ogrlinearring_touches ::
+               Ptr RawOGRLinearRing -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Crosses"
+               c_ogrlinearring_crosses ::
+               Ptr RawOGRLinearRing -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Within" c_ogrlinearring_within
+               :: Ptr RawOGRLinearRing -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Contains"
+               c_ogrlinearring_contains ::
+               Ptr RawOGRLinearRing -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Overlaps"
+               c_ogrlinearring_overlaps ::
+               Ptr RawOGRLinearRing -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Boundary"
+               c_ogrlinearring_boundary ::
+               Ptr RawOGRLinearRing -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Distance"
+               c_ogrlinearring_distance ::
+               Ptr RawOGRLinearRing -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_ConvexHull"
+               c_ogrlinearring_convexhull ::
+               Ptr RawOGRLinearRing -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Buffer" c_ogrlinearring_buffer
+               ::
+               Ptr RawOGRLinearRing -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Intersection"
+               c_ogrlinearring_intersection ::
+               Ptr RawOGRLinearRing ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Union" c_ogrlinearring_union ::
+               Ptr RawOGRLinearRing ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_UnionCascaded"
+               c_ogrlinearring_unioncascaded ::
+               Ptr RawOGRLinearRing -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Difference"
+               c_ogrlinearring_difference ::
+               Ptr RawOGRLinearRing ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_SymDifference"
+               c_ogrlinearring_symdifference ::
+               Ptr RawOGRLinearRing ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Centroid"
+               c_ogrlinearring_centroid ::
+               Ptr RawOGRLinearRing -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Simplify"
+               c_ogrlinearring_simplify ::
+               Ptr RawOGRLinearRing -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_DelaunayTriangulation"
+               c_ogrlinearring_delaunaytriangulation ::
+               Ptr RawOGRLinearRing -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Polygonize"
+               c_ogrlinearring_polygonize ::
+               Ptr RawOGRLinearRing -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_Distance3D"
+               c_ogrlinearring_distance3d ::
+               Ptr RawOGRLinearRing -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRLinearRing.h OGRLinearRing_delete" c_ogrlinearring_delete
+               :: Ptr RawOGRLinearRing -> IO ()
diff --git a/src/GDAL/OGRLinearRing/Implementation.hs b/src/GDAL/OGRLinearRing/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLinearRing/Implementation.hs
@@ -0,0 +1,93 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRLinearRing.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRLinearRing.RawType
+import GDAL.OGRLinearRing.FFI
+import GDAL.OGRLinearRing.Interface
+import GDAL.OGRLinearRing.Cast
+import GDAL.OGRLinearRing.RawType
+import GDAL.OGRLinearRing.Cast
+import GDAL.OGRLinearRing.Interface
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRPointIterator.Cast
+import GDAL.OGRPointIterator.Interface
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import GDAL.OGRLineString.RawType
+import GDAL.OGRLineString.Cast
+import GDAL.OGRLineString.Interface
+import GDAL.OGRSimpleCurve.RawType
+import GDAL.OGRSimpleCurve.Cast
+import GDAL.OGRSimpleCurve.Interface
+import GDAL.OGRCurve.RawType
+import GDAL.OGRCurve.Cast
+import GDAL.OGRCurve.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRLinearRing (OGRLinearRing) where
+
+instance () => IOGRLineString (OGRLinearRing) where
+
+instance () => IOGRSimpleCurve (OGRLinearRing) where
+
+instance () => IOGRCurve (OGRLinearRing) where
+        getNumPoints = xform0 c_ogrlinearring_getnumpoints
+        getPointIterator = xform0 c_ogrlinearring_getpointiterator
+
+instance () => IOGRGeometry (OGRLinearRing) where
+        getGeometryType = xform0 c_ogrlinearring_getgeometrytype
+        getEnvelope = xform1 c_ogrlinearring_getenvelope
+        intersects = xform1 c_ogrlinearring_intersects
+        equals = xform1 c_ogrlinearring_equals
+        disjoint = xform1 c_ogrlinearring_disjoint
+        touches = xform1 c_ogrlinearring_touches
+        crosses = xform1 c_ogrlinearring_crosses
+        within = xform1 c_ogrlinearring_within
+        contains = xform1 c_ogrlinearring_contains
+        overlaps = xform1 c_ogrlinearring_overlaps
+        boundary = xform0 c_ogrlinearring_boundary
+        distance = xform1 c_ogrlinearring_distance
+        convexHull = xform0 c_ogrlinearring_convexhull
+        buffer = xform2 c_ogrlinearring_buffer
+        intersection = xform1 c_ogrlinearring_intersection
+        union = xform1 c_ogrlinearring_union
+        unionCascaded = xform0 c_ogrlinearring_unioncascaded
+        difference = xform1 c_ogrlinearring_difference
+        symDifference = xform1 c_ogrlinearring_symdifference
+        centroid = xform1 c_ogrlinearring_centroid
+        simplify = xform1 c_ogrlinearring_simplify
+        delaunayTriangulation
+          = xform2 c_ogrlinearring_delaunaytriangulation
+        polygonize = xform0 c_ogrlinearring_polygonize
+        distance3D = xform1 c_ogrlinearring_distance3d
+
+instance () => IDeletable (OGRLinearRing) where
+        delete = xform0 c_ogrlinearring_delete
diff --git a/src/GDAL/OGRLinearRing/Interface.hs b/src/GDAL/OGRLinearRing/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLinearRing/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRLinearRing.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRLinearRing.RawType
+import GDAL.OGRLineString.Interface
+
+class (IOGRLineString a) => IOGRLinearRing a where
+
+upcastOGRLinearRing ::
+                    forall a . (FPtr a, IOGRLinearRing a) => a -> OGRLinearRing
+upcastOGRLinearRing h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRLinearRing = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRLinearRing ::
+                      forall a . (FPtr a, IOGRLinearRing a) => OGRLinearRing -> a
+downcastOGRLinearRing h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRLinearRing/RawType.hs b/src/GDAL/OGRLinearRing/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRLinearRing/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRLinearRing.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRLinearRing
+
+newtype OGRLinearRing = OGRLinearRing (Ptr RawOGRLinearRing)
+                          deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRLinearRing) where
+        type Raw OGRLinearRing = RawOGRLinearRing
+        get_fptr (OGRLinearRing ptr) = ptr
+        cast_fptr_to_obj = OGRLinearRing
diff --git a/src/GDAL/OGRMultiPolygon.hs b/src/GDAL/OGRMultiPolygon.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiPolygon.hs
@@ -0,0 +1,7 @@
+module GDAL.OGRMultiPolygon
+       (OGRMultiPolygon(..), IOGRMultiPolygon, upcastOGRMultiPolygon,
+        downcastOGRMultiPolygon)
+       where
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGRMultiPolygon.Implementation
diff --git a/src/GDAL/OGRMultiPolygon/Cast.hs b/src/GDAL/OGRMultiPolygon/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiPolygon/Cast.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRMultiPolygon.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Interface
+
+instance (IOGRMultiPolygon a, FPtr a) =>
+         Castable (a) (Ptr RawOGRMultiPolygon)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRMultiPolygon) (Ptr RawOGRMultiPolygon)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRMultiPolygon/FFI.hsc b/src/GDAL/OGRMultiPolygon/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiPolygon/FFI.hsc
@@ -0,0 +1,142 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRMultiPolygon.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGREnvelope.RawType
+import GDAL.OGRPoint.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_getGeometryType"
+               c_ogrmultipolygon_getgeometrytype ::
+               Ptr RawOGRMultiPolygon -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_getEnvelope"
+               c_ogrmultipolygon_getenvelope ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Intersects"
+               c_ogrmultipolygon_intersects ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Equals"
+               c_ogrmultipolygon_equals ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Disjoint"
+               c_ogrmultipolygon_disjoint ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Touches"
+               c_ogrmultipolygon_touches ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Crosses"
+               c_ogrmultipolygon_crosses ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Within"
+               c_ogrmultipolygon_within ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Contains"
+               c_ogrmultipolygon_contains ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Overlaps"
+               c_ogrmultipolygon_overlaps ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Boundary"
+               c_ogrmultipolygon_boundary ::
+               Ptr RawOGRMultiPolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Distance"
+               c_ogrmultipolygon_distance ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_ConvexHull"
+               c_ogrmultipolygon_convexhull ::
+               Ptr RawOGRMultiPolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Buffer"
+               c_ogrmultipolygon_buffer ::
+               Ptr RawOGRMultiPolygon ->
+                 CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Intersection"
+               c_ogrmultipolygon_intersection ::
+               Ptr RawOGRMultiPolygon ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Union"
+               c_ogrmultipolygon_union ::
+               Ptr RawOGRMultiPolygon ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_UnionCascaded"
+               c_ogrmultipolygon_unioncascaded ::
+               Ptr RawOGRMultiPolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Difference"
+               c_ogrmultipolygon_difference ::
+               Ptr RawOGRMultiPolygon ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_SymDifference"
+               c_ogrmultipolygon_symdifference ::
+               Ptr RawOGRMultiPolygon ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Centroid"
+               c_ogrmultipolygon_centroid ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Simplify"
+               c_ogrmultipolygon_simplify ::
+               Ptr RawOGRMultiPolygon -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_DelaunayTriangulation"
+               c_ogrmultipolygon_delaunaytriangulation ::
+               Ptr RawOGRMultiPolygon ->
+                 CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Polygonize"
+               c_ogrmultipolygon_polygonize ::
+               Ptr RawOGRMultiPolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_Distance3D"
+               c_ogrmultipolygon_distance3d ::
+               Ptr RawOGRMultiPolygon -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRMultiPolygon.h OGRMultiPolygon_delete"
+               c_ogrmultipolygon_delete :: Ptr RawOGRMultiPolygon -> IO ()
diff --git a/src/GDAL/OGRMultiPolygon/Implementation.hs b/src/GDAL/OGRMultiPolygon/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiPolygon/Implementation.hs
@@ -0,0 +1,80 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRMultiPolygon.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.FFI
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import GDAL.OGRMultiSurface.RawType
+import GDAL.OGRMultiSurface.Cast
+import GDAL.OGRMultiSurface.Interface
+import GDAL.OGRGeometryCollection.RawType
+import GDAL.OGRGeometryCollection.Cast
+import GDAL.OGRGeometryCollection.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRMultiPolygon (OGRMultiPolygon) where
+
+instance () => IOGRMultiSurface (OGRMultiPolygon) where
+
+instance () => IOGRGeometryCollection (OGRMultiPolygon) where
+
+instance () => IOGRGeometry (OGRMultiPolygon) where
+        getGeometryType = xform0 c_ogrmultipolygon_getgeometrytype
+        getEnvelope = xform1 c_ogrmultipolygon_getenvelope
+        intersects = xform1 c_ogrmultipolygon_intersects
+        equals = xform1 c_ogrmultipolygon_equals
+        disjoint = xform1 c_ogrmultipolygon_disjoint
+        touches = xform1 c_ogrmultipolygon_touches
+        crosses = xform1 c_ogrmultipolygon_crosses
+        within = xform1 c_ogrmultipolygon_within
+        contains = xform1 c_ogrmultipolygon_contains
+        overlaps = xform1 c_ogrmultipolygon_overlaps
+        boundary = xform0 c_ogrmultipolygon_boundary
+        distance = xform1 c_ogrmultipolygon_distance
+        convexHull = xform0 c_ogrmultipolygon_convexhull
+        buffer = xform2 c_ogrmultipolygon_buffer
+        intersection = xform1 c_ogrmultipolygon_intersection
+        union = xform1 c_ogrmultipolygon_union
+        unionCascaded = xform0 c_ogrmultipolygon_unioncascaded
+        difference = xform1 c_ogrmultipolygon_difference
+        symDifference = xform1 c_ogrmultipolygon_symdifference
+        centroid = xform1 c_ogrmultipolygon_centroid
+        simplify = xform1 c_ogrmultipolygon_simplify
+        delaunayTriangulation
+          = xform2 c_ogrmultipolygon_delaunaytriangulation
+        polygonize = xform0 c_ogrmultipolygon_polygonize
+        distance3D = xform1 c_ogrmultipolygon_distance3d
+
+instance () => IDeletable (OGRMultiPolygon) where
+        delete = xform0 c_ogrmultipolygon_delete
diff --git a/src/GDAL/OGRMultiPolygon/Interface.hs b/src/GDAL/OGRMultiPolygon/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiPolygon/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRMultiPolygon.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiSurface.Interface
+
+class (IOGRMultiSurface a) => IOGRMultiPolygon a where
+
+upcastOGRMultiPolygon ::
+                      forall a . (FPtr a, IOGRMultiPolygon a) => a -> OGRMultiPolygon
+upcastOGRMultiPolygon h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRMultiPolygon = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRMultiPolygon ::
+                        forall a . (FPtr a, IOGRMultiPolygon a) => OGRMultiPolygon -> a
+downcastOGRMultiPolygon h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRMultiPolygon/RawType.hs b/src/GDAL/OGRMultiPolygon/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiPolygon/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRMultiPolygon.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRMultiPolygon
+
+newtype OGRMultiPolygon = OGRMultiPolygon (Ptr RawOGRMultiPolygon)
+                            deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRMultiPolygon) where
+        type Raw OGRMultiPolygon = RawOGRMultiPolygon
+        get_fptr (OGRMultiPolygon ptr) = ptr
+        cast_fptr_to_obj = OGRMultiPolygon
diff --git a/src/GDAL/OGRMultiSurface.hs b/src/GDAL/OGRMultiSurface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiSurface.hs
@@ -0,0 +1,7 @@
+module GDAL.OGRMultiSurface
+       (OGRMultiSurface(..), IOGRMultiSurface, upcastOGRMultiSurface,
+        downcastOGRMultiSurface)
+       where
+import GDAL.OGRMultiSurface.RawType
+import GDAL.OGRMultiSurface.Interface
+import GDAL.OGRMultiSurface.Implementation
diff --git a/src/GDAL/OGRMultiSurface/Cast.hs b/src/GDAL/OGRMultiSurface/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiSurface/Cast.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRMultiSurface.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRMultiSurface.RawType
+import GDAL.OGRMultiSurface.Interface
+
+instance (IOGRMultiSurface a, FPtr a) =>
+         Castable (a) (Ptr RawOGRMultiSurface)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRMultiSurface) (Ptr RawOGRMultiSurface)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRMultiSurface/FFI.hsc b/src/GDAL/OGRMultiSurface/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiSurface/FFI.hsc
@@ -0,0 +1,143 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRMultiSurface.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRMultiSurface.RawType
+import GDAL.OGRMultiSurface.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGREnvelope.RawType
+import GDAL.OGRPoint.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_getGeometryType"
+               c_ogrmultisurface_getgeometrytype ::
+               Ptr RawOGRMultiSurface -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_getEnvelope"
+               c_ogrmultisurface_getenvelope ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Intersects"
+               c_ogrmultisurface_intersects ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Equals"
+               c_ogrmultisurface_equals ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Disjoint"
+               c_ogrmultisurface_disjoint ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Touches"
+               c_ogrmultisurface_touches ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Crosses"
+               c_ogrmultisurface_crosses ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Within"
+               c_ogrmultisurface_within ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Contains"
+               c_ogrmultisurface_contains ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Overlaps"
+               c_ogrmultisurface_overlaps ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Boundary"
+               c_ogrmultisurface_boundary ::
+               Ptr RawOGRMultiSurface -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Distance"
+               c_ogrmultisurface_distance ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_ConvexHull"
+               c_ogrmultisurface_convexhull ::
+               Ptr RawOGRMultiSurface -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Buffer"
+               c_ogrmultisurface_buffer ::
+               Ptr RawOGRMultiSurface ->
+                 CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Intersection"
+               c_ogrmultisurface_intersection ::
+               Ptr RawOGRMultiSurface ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Union"
+               c_ogrmultisurface_union ::
+               Ptr RawOGRMultiSurface ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_UnionCascaded"
+               c_ogrmultisurface_unioncascaded ::
+               Ptr RawOGRMultiSurface -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Difference"
+               c_ogrmultisurface_difference ::
+               Ptr RawOGRMultiSurface ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_SymDifference"
+               c_ogrmultisurface_symdifference ::
+               Ptr RawOGRMultiSurface ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Centroid"
+               c_ogrmultisurface_centroid ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Simplify"
+               c_ogrmultisurface_simplify ::
+               Ptr RawOGRMultiSurface -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_DelaunayTriangulation"
+               c_ogrmultisurface_delaunaytriangulation ::
+               Ptr RawOGRMultiSurface ->
+                 CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Polygonize"
+               c_ogrmultisurface_polygonize ::
+               Ptr RawOGRMultiSurface -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_Distance3D"
+               c_ogrmultisurface_distance3d ::
+               Ptr RawOGRMultiSurface -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRMultiSurface.h OGRMultiSurface_delete"
+               c_ogrmultisurface_delete :: Ptr RawOGRMultiSurface -> IO ()
diff --git a/src/GDAL/OGRMultiSurface/Implementation.hs b/src/GDAL/OGRMultiSurface/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiSurface/Implementation.hs
@@ -0,0 +1,78 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRMultiSurface.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRMultiSurface.RawType
+import GDAL.OGRMultiSurface.FFI
+import GDAL.OGRMultiSurface.Interface
+import GDAL.OGRMultiSurface.Cast
+import GDAL.OGRMultiSurface.RawType
+import GDAL.OGRMultiSurface.Cast
+import GDAL.OGRMultiSurface.Interface
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import GDAL.OGRGeometryCollection.RawType
+import GDAL.OGRGeometryCollection.Cast
+import GDAL.OGRGeometryCollection.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRMultiSurface (OGRMultiSurface) where
+
+instance () => IOGRGeometryCollection (OGRMultiSurface) where
+
+instance () => IOGRGeometry (OGRMultiSurface) where
+        getGeometryType = xform0 c_ogrmultisurface_getgeometrytype
+        getEnvelope = xform1 c_ogrmultisurface_getenvelope
+        intersects = xform1 c_ogrmultisurface_intersects
+        equals = xform1 c_ogrmultisurface_equals
+        disjoint = xform1 c_ogrmultisurface_disjoint
+        touches = xform1 c_ogrmultisurface_touches
+        crosses = xform1 c_ogrmultisurface_crosses
+        within = xform1 c_ogrmultisurface_within
+        contains = xform1 c_ogrmultisurface_contains
+        overlaps = xform1 c_ogrmultisurface_overlaps
+        boundary = xform0 c_ogrmultisurface_boundary
+        distance = xform1 c_ogrmultisurface_distance
+        convexHull = xform0 c_ogrmultisurface_convexhull
+        buffer = xform2 c_ogrmultisurface_buffer
+        intersection = xform1 c_ogrmultisurface_intersection
+        union = xform1 c_ogrmultisurface_union
+        unionCascaded = xform0 c_ogrmultisurface_unioncascaded
+        difference = xform1 c_ogrmultisurface_difference
+        symDifference = xform1 c_ogrmultisurface_symdifference
+        centroid = xform1 c_ogrmultisurface_centroid
+        simplify = xform1 c_ogrmultisurface_simplify
+        delaunayTriangulation
+          = xform2 c_ogrmultisurface_delaunaytriangulation
+        polygonize = xform0 c_ogrmultisurface_polygonize
+        distance3D = xform1 c_ogrmultisurface_distance3d
+
+instance () => IDeletable (OGRMultiSurface) where
+        delete = xform0 c_ogrmultisurface_delete
diff --git a/src/GDAL/OGRMultiSurface/Interface.hs b/src/GDAL/OGRMultiSurface/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiSurface/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRMultiSurface.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRMultiSurface.RawType
+import GDAL.OGRGeometryCollection.Interface
+
+class (IOGRGeometryCollection a) => IOGRMultiSurface a where
+
+upcastOGRMultiSurface ::
+                      forall a . (FPtr a, IOGRMultiSurface a) => a -> OGRMultiSurface
+upcastOGRMultiSurface h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRMultiSurface = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRMultiSurface ::
+                        forall a . (FPtr a, IOGRMultiSurface a) => OGRMultiSurface -> a
+downcastOGRMultiSurface h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRMultiSurface/RawType.hs b/src/GDAL/OGRMultiSurface/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRMultiSurface/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRMultiSurface.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRMultiSurface
+
+newtype OGRMultiSurface = OGRMultiSurface (Ptr RawOGRMultiSurface)
+                            deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRMultiSurface) where
+        type Raw OGRMultiSurface = RawOGRMultiSurface
+        get_fptr (OGRMultiSurface ptr) = ptr
+        cast_fptr_to_obj = OGRMultiSurface
diff --git a/src/GDAL/OGRPoint.hs b/src/GDAL/OGRPoint.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPoint.hs
@@ -0,0 +1,9 @@
+module GDAL.OGRPoint
+       (OGRPoint(..), IOGRPoint, upcastOGRPoint, downcastOGRPoint,
+        newOGRPoint, newOGRPoint2, newOGRPoint3, newOGRPoint4,
+        oGRPoint_getX, oGRPoint_getY, oGRPoint_getZ, oGRPoint_getM,
+        oGRPoint_setX, oGRPoint_setY, oGRPoint_setZ, oGRPoint_setM)
+       where
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Interface
+import GDAL.OGRPoint.Implementation
diff --git a/src/GDAL/OGRPoint/Cast.hs b/src/GDAL/OGRPoint/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPoint/Cast.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRPoint.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Interface
+
+instance (IOGRPoint a, FPtr a) => Castable (a) (Ptr RawOGRPoint)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRPoint) (Ptr RawOGRPoint) where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRPoint/FFI.hsc b/src/GDAL/OGRPoint/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPoint/FFI.hsc
@@ -0,0 +1,161 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRPoint.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGREnvelope.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_getGeometryType"
+               c_ogrpoint_getgeometrytype :: Ptr RawOGRPoint -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_getEnvelope" c_ogrpoint_getenvelope ::
+               Ptr RawOGRPoint -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Intersects" c_ogrpoint_intersects ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Equals" c_ogrpoint_equals ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Disjoint" c_ogrpoint_disjoint ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Touches" c_ogrpoint_touches ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Crosses" c_ogrpoint_crosses ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Within" c_ogrpoint_within ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Contains" c_ogrpoint_contains ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Overlaps" c_ogrpoint_overlaps ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Boundary" c_ogrpoint_boundary ::
+               Ptr RawOGRPoint -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Distance" c_ogrpoint_distance ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_ConvexHull" c_ogrpoint_convexhull ::
+               Ptr RawOGRPoint -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Buffer" c_ogrpoint_buffer ::
+               Ptr RawOGRPoint -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Intersection" c_ogrpoint_intersection ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible "HGDALOGRPoint.h OGRPoint_Union"
+               c_ogrpoint_union ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_UnionCascaded" c_ogrpoint_unioncascaded
+               :: Ptr RawOGRPoint -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Difference" c_ogrpoint_difference ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_SymDifference" c_ogrpoint_symdifference
+               :: Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Centroid" c_ogrpoint_centroid ::
+               Ptr RawOGRPoint -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Simplify" c_ogrpoint_simplify ::
+               Ptr RawOGRPoint -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_DelaunayTriangulation"
+               c_ogrpoint_delaunaytriangulation ::
+               Ptr RawOGRPoint -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Polygonize" c_ogrpoint_polygonize ::
+               Ptr RawOGRPoint -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_Distance3D" c_ogrpoint_distance3d ::
+               Ptr RawOGRPoint -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_delete" c_ogrpoint_delete ::
+               Ptr RawOGRPoint -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_newOGRPoint" c_ogrpoint_newogrpoint ::
+               IO (Ptr RawOGRPoint)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_newOGRPoint2" c_ogrpoint_newogrpoint2 ::
+               CDouble -> CDouble -> IO (Ptr RawOGRPoint)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_newOGRPoint3" c_ogrpoint_newogrpoint3 ::
+               CDouble -> CDouble -> CDouble -> IO (Ptr RawOGRPoint)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_newOGRPoint4" c_ogrpoint_newogrpoint4 ::
+               CDouble -> CDouble -> CDouble -> CDouble -> IO (Ptr RawOGRPoint)
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_oGRPoint_getX" c_ogrpoint_ogrpoint_getx
+               :: Ptr RawOGRPoint -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_oGRPoint_getY" c_ogrpoint_ogrpoint_gety
+               :: Ptr RawOGRPoint -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_oGRPoint_getZ" c_ogrpoint_ogrpoint_getz
+               :: Ptr RawOGRPoint -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_oGRPoint_getM" c_ogrpoint_ogrpoint_getm
+               :: Ptr RawOGRPoint -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_oGRPoint_setX" c_ogrpoint_ogrpoint_setx
+               :: Ptr RawOGRPoint -> CDouble -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_oGRPoint_setY" c_ogrpoint_ogrpoint_sety
+               :: Ptr RawOGRPoint -> CDouble -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_oGRPoint_setZ" c_ogrpoint_ogrpoint_setz
+               :: Ptr RawOGRPoint -> CDouble -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRPoint.h OGRPoint_oGRPoint_setM" c_ogrpoint_ogrpoint_setm
+               :: Ptr RawOGRPoint -> CDouble -> IO ()
diff --git a/src/GDAL/OGRPoint/Implementation.hs b/src/GDAL/OGRPoint/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPoint/Implementation.hs
@@ -0,0 +1,106 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRPoint.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.FFI
+import GDAL.OGRPoint.Interface
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRPoint (OGRPoint) where
+
+instance () => IOGRGeometry (OGRPoint) where
+        getGeometryType = xform0 c_ogrpoint_getgeometrytype
+        getEnvelope = xform1 c_ogrpoint_getenvelope
+        intersects = xform1 c_ogrpoint_intersects
+        equals = xform1 c_ogrpoint_equals
+        disjoint = xform1 c_ogrpoint_disjoint
+        touches = xform1 c_ogrpoint_touches
+        crosses = xform1 c_ogrpoint_crosses
+        within = xform1 c_ogrpoint_within
+        contains = xform1 c_ogrpoint_contains
+        overlaps = xform1 c_ogrpoint_overlaps
+        boundary = xform0 c_ogrpoint_boundary
+        distance = xform1 c_ogrpoint_distance
+        convexHull = xform0 c_ogrpoint_convexhull
+        buffer = xform2 c_ogrpoint_buffer
+        intersection = xform1 c_ogrpoint_intersection
+        union = xform1 c_ogrpoint_union
+        unionCascaded = xform0 c_ogrpoint_unioncascaded
+        difference = xform1 c_ogrpoint_difference
+        symDifference = xform1 c_ogrpoint_symdifference
+        centroid = xform1 c_ogrpoint_centroid
+        simplify = xform1 c_ogrpoint_simplify
+        delaunayTriangulation = xform2 c_ogrpoint_delaunaytriangulation
+        polygonize = xform0 c_ogrpoint_polygonize
+        distance3D = xform1 c_ogrpoint_distance3d
+
+instance () => IDeletable (OGRPoint) where
+        delete = xform0 c_ogrpoint_delete
+
+newOGRPoint :: () => IO OGRPoint
+newOGRPoint = xformnull c_ogrpoint_newogrpoint
+
+newOGRPoint2 :: () => CDouble -> CDouble -> IO OGRPoint
+newOGRPoint2 = xform1 c_ogrpoint_newogrpoint2
+
+newOGRPoint3 :: () => CDouble -> CDouble -> CDouble -> IO OGRPoint
+newOGRPoint3 = xform2 c_ogrpoint_newogrpoint3
+
+newOGRPoint4 ::
+               () => CDouble -> CDouble -> CDouble -> CDouble -> IO OGRPoint
+newOGRPoint4 = xform3 c_ogrpoint_newogrpoint4
+
+oGRPoint_getX :: () => OGRPoint -> IO CDouble
+oGRPoint_getX = xform0 c_ogrpoint_ogrpoint_getx
+
+oGRPoint_getY :: () => OGRPoint -> IO CDouble
+oGRPoint_getY = xform0 c_ogrpoint_ogrpoint_gety
+
+oGRPoint_getZ :: () => OGRPoint -> IO CDouble
+oGRPoint_getZ = xform0 c_ogrpoint_ogrpoint_getz
+
+oGRPoint_getM :: () => OGRPoint -> IO CDouble
+oGRPoint_getM = xform0 c_ogrpoint_ogrpoint_getm
+
+oGRPoint_setX :: () => OGRPoint -> CDouble -> IO ()
+oGRPoint_setX = xform1 c_ogrpoint_ogrpoint_setx
+
+oGRPoint_setY :: () => OGRPoint -> CDouble -> IO ()
+oGRPoint_setY = xform1 c_ogrpoint_ogrpoint_sety
+
+oGRPoint_setZ :: () => OGRPoint -> CDouble -> IO ()
+oGRPoint_setZ = xform1 c_ogrpoint_ogrpoint_setz
+
+oGRPoint_setM :: () => OGRPoint -> CDouble -> IO ()
+oGRPoint_setM = xform1 c_ogrpoint_ogrpoint_setm
diff --git a/src/GDAL/OGRPoint/Interface.hs b/src/GDAL/OGRPoint/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPoint/Interface.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRPoint.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRPoint.RawType
+import GDAL.OGRGeometry.Interface
+
+class (IOGRGeometry a) => IOGRPoint a where
+
+upcastOGRPoint :: forall a . (FPtr a, IOGRPoint a) => a -> OGRPoint
+upcastOGRPoint h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRPoint = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRPoint ::
+                 forall a . (FPtr a, IOGRPoint a) => OGRPoint -> a
+downcastOGRPoint h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRPoint/Interface.hs-boot b/src/GDAL/OGRPoint/Interface.hs-boot
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPoint/Interface.hs-boot
@@ -0,0 +1,13 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRPoint.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRPoint.RawType
+
+class  IOGRPoint a where
diff --git a/src/GDAL/OGRPoint/RawType.hs b/src/GDAL/OGRPoint/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPoint/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRPoint.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRPoint
+
+newtype OGRPoint = OGRPoint (Ptr RawOGRPoint)
+                     deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRPoint) where
+        type Raw OGRPoint = RawOGRPoint
+        get_fptr (OGRPoint ptr) = ptr
+        cast_fptr_to_obj = OGRPoint
diff --git a/src/GDAL/OGRPointIterator.hs b/src/GDAL/OGRPointIterator.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPointIterator.hs
@@ -0,0 +1,7 @@
+module GDAL.OGRPointIterator
+       (OGRPointIterator(..), IOGRPointIterator(..),
+        upcastOGRPointIterator, downcastOGRPointIterator)
+       where
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRPointIterator.Interface
+import GDAL.OGRPointIterator.Implementation
diff --git a/src/GDAL/OGRPointIterator/Cast.hs b/src/GDAL/OGRPointIterator/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPointIterator/Cast.hs
@@ -0,0 +1,21 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRPointIterator.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRPointIterator.Interface
+
+instance (IOGRPointIterator a, FPtr a) =>
+         Castable (a) (Ptr RawOGRPointIterator)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () =>
+         Castable (OGRPointIterator) (Ptr RawOGRPointIterator)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRPointIterator/FFI.hsc b/src/GDAL/OGRPointIterator/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPointIterator/FFI.hsc
@@ -0,0 +1,18 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRPointIterator.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRPoint.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRPointIterator.h OGRPointIterator_delete"
+               c_ogrpointiterator_delete :: Ptr RawOGRPointIterator -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRPointIterator.h OGRPointIterator_getNextPoint"
+               c_ogrpointiterator_getnextpoint ::
+               Ptr RawOGRPointIterator -> Ptr RawOGRPoint -> IO CBool
diff --git a/src/GDAL/OGRPointIterator/Implementation.hs b/src/GDAL/OGRPointIterator/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPointIterator/Implementation.hs
@@ -0,0 +1,35 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRPointIterator.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRPointIterator.FFI
+import GDAL.OGRPointIterator.Interface
+import GDAL.OGRPointIterator.Cast
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRPointIterator.Cast
+import GDAL.OGRPointIterator.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRPointIterator (OGRPointIterator) where
+        getNextPoint = xform1 c_ogrpointiterator_getnextpoint
+
+instance () => IDeletable (OGRPointIterator) where
+        delete = xform0 c_ogrpointiterator_delete
diff --git a/src/GDAL/OGRPointIterator/Interface.hs b/src/GDAL/OGRPointIterator/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPointIterator/Interface.hs
@@ -0,0 +1,30 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRPointIterator.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRPointIterator.RawType
+import STD.Deletable.Interface
+import GDAL.OGRPoint.Interface
+
+class (IDeletable a) => IOGRPointIterator a where
+        getNextPoint :: (IOGRPoint c0, FPtr c0) => a -> c0 -> IO CBool
+
+upcastOGRPointIterator ::
+                       forall a . (FPtr a, IOGRPointIterator a) => a -> OGRPointIterator
+upcastOGRPointIterator h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRPointIterator = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRPointIterator ::
+                         forall a . (FPtr a, IOGRPointIterator a) => OGRPointIterator -> a
+downcastOGRPointIterator h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRPointIterator/RawType.hs b/src/GDAL/OGRPointIterator/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPointIterator/RawType.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRPointIterator.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRPointIterator
+
+newtype OGRPointIterator = OGRPointIterator (Ptr
+                                               RawOGRPointIterator)
+                             deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRPointIterator) where
+        type Raw OGRPointIterator = RawOGRPointIterator
+        get_fptr (OGRPointIterator ptr) = ptr
+        cast_fptr_to_obj = OGRPointIterator
diff --git a/src/GDAL/OGRPolygon.hs b/src/GDAL/OGRPolygon.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPolygon.hs
@@ -0,0 +1,7 @@
+module GDAL.OGRPolygon
+       (OGRPolygon(..), IOGRPolygon, upcastOGRPolygon, downcastOGRPolygon,
+        oGRPolygon_getExteriorRing)
+       where
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRPolygon.Implementation
diff --git a/src/GDAL/OGRPolygon/Cast.hs b/src/GDAL/OGRPolygon/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPolygon/Cast.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRPolygon.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Interface
+
+instance (IOGRPolygon a, FPtr a) =>
+         Castable (a) (Ptr RawOGRPolygon)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRPolygon) (Ptr RawOGRPolygon) where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRPolygon/FFI.hsc b/src/GDAL/OGRPolygon/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPolygon/FFI.hsc
@@ -0,0 +1,123 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRPolygon.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGREnvelope.RawType
+import GDAL.OGRPoint.RawType
+import GDAL.OGRLinearRing.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_getGeometryType"
+               c_ogrpolygon_getgeometrytype :: Ptr RawOGRPolygon -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_getEnvelope" c_ogrpolygon_getenvelope
+               :: Ptr RawOGRPolygon -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Intersects" c_ogrpolygon_intersects
+               :: Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Equals" c_ogrpolygon_equals ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Disjoint" c_ogrpolygon_disjoint ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Touches" c_ogrpolygon_touches ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Crosses" c_ogrpolygon_crosses ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Within" c_ogrpolygon_within ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Contains" c_ogrpolygon_contains ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Overlaps" c_ogrpolygon_overlaps ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Boundary" c_ogrpolygon_boundary ::
+               Ptr RawOGRPolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Distance" c_ogrpolygon_distance ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_ConvexHull" c_ogrpolygon_convexhull
+               :: Ptr RawOGRPolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Buffer" c_ogrpolygon_buffer ::
+               Ptr RawOGRPolygon -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Intersection"
+               c_ogrpolygon_intersection ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Union" c_ogrpolygon_union ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_UnionCascaded"
+               c_ogrpolygon_unioncascaded ::
+               Ptr RawOGRPolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Difference" c_ogrpolygon_difference
+               ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_SymDifference"
+               c_ogrpolygon_symdifference ::
+               Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Centroid" c_ogrpolygon_centroid ::
+               Ptr RawOGRPolygon -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Simplify" c_ogrpolygon_simplify ::
+               Ptr RawOGRPolygon -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_DelaunayTriangulation"
+               c_ogrpolygon_delaunaytriangulation ::
+               Ptr RawOGRPolygon -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Polygonize" c_ogrpolygon_polygonize
+               :: Ptr RawOGRPolygon -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_Distance3D" c_ogrpolygon_distance3d
+               :: Ptr RawOGRPolygon -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_delete" c_ogrpolygon_delete ::
+               Ptr RawOGRPolygon -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRPolygon.h OGRPolygon_oGRPolygon_getExteriorRing"
+               c_ogrpolygon_ogrpolygon_getexteriorring ::
+               Ptr RawOGRPolygon -> IO (Ptr RawOGRLinearRing)
diff --git a/src/GDAL/OGRPolygon/Implementation.hs b/src/GDAL/OGRPolygon/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPolygon/Implementation.hs
@@ -0,0 +1,86 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRPolygon.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.FFI
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import GDAL.OGRLinearRing.RawType
+import GDAL.OGRLinearRing.Cast
+import GDAL.OGRLinearRing.Interface
+import GDAL.OGRCurvePolygon.RawType
+import GDAL.OGRCurvePolygon.Cast
+import GDAL.OGRCurvePolygon.Interface
+import GDAL.OGRSurface.RawType
+import GDAL.OGRSurface.Cast
+import GDAL.OGRSurface.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRPolygon (OGRPolygon) where
+
+instance () => IOGRCurvePolygon (OGRPolygon) where
+
+instance () => IOGRSurface (OGRPolygon) where
+
+instance () => IOGRGeometry (OGRPolygon) where
+        getGeometryType = xform0 c_ogrpolygon_getgeometrytype
+        getEnvelope = xform1 c_ogrpolygon_getenvelope
+        intersects = xform1 c_ogrpolygon_intersects
+        equals = xform1 c_ogrpolygon_equals
+        disjoint = xform1 c_ogrpolygon_disjoint
+        touches = xform1 c_ogrpolygon_touches
+        crosses = xform1 c_ogrpolygon_crosses
+        within = xform1 c_ogrpolygon_within
+        contains = xform1 c_ogrpolygon_contains
+        overlaps = xform1 c_ogrpolygon_overlaps
+        boundary = xform0 c_ogrpolygon_boundary
+        distance = xform1 c_ogrpolygon_distance
+        convexHull = xform0 c_ogrpolygon_convexhull
+        buffer = xform2 c_ogrpolygon_buffer
+        intersection = xform1 c_ogrpolygon_intersection
+        union = xform1 c_ogrpolygon_union
+        unionCascaded = xform0 c_ogrpolygon_unioncascaded
+        difference = xform1 c_ogrpolygon_difference
+        symDifference = xform1 c_ogrpolygon_symdifference
+        centroid = xform1 c_ogrpolygon_centroid
+        simplify = xform1 c_ogrpolygon_simplify
+        delaunayTriangulation = xform2 c_ogrpolygon_delaunaytriangulation
+        polygonize = xform0 c_ogrpolygon_polygonize
+        distance3D = xform1 c_ogrpolygon_distance3d
+
+instance () => IDeletable (OGRPolygon) where
+        delete = xform0 c_ogrpolygon_delete
+
+oGRPolygon_getExteriorRing :: () => OGRPolygon -> IO OGRLinearRing
+oGRPolygon_getExteriorRing
+  = xform0 c_ogrpolygon_ogrpolygon_getexteriorring
diff --git a/src/GDAL/OGRPolygon/Interface.hs b/src/GDAL/OGRPolygon/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPolygon/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRPolygon.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRCurvePolygon.Interface
+
+class (IOGRCurvePolygon a) => IOGRPolygon a where
+
+upcastOGRPolygon ::
+                 forall a . (FPtr a, IOGRPolygon a) => a -> OGRPolygon
+upcastOGRPolygon h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRPolygon = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRPolygon ::
+                   forall a . (FPtr a, IOGRPolygon a) => OGRPolygon -> a
+downcastOGRPolygon h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRPolygon/RawType.hs b/src/GDAL/OGRPolygon/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRPolygon/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRPolygon.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRPolygon
+
+newtype OGRPolygon = OGRPolygon (Ptr RawOGRPolygon)
+                       deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRPolygon) where
+        type Raw OGRPolygon = RawOGRPolygon
+        get_fptr (OGRPolygon ptr) = ptr
+        cast_fptr_to_obj = OGRPolygon
diff --git a/src/GDAL/OGRSimpleCurve.hs b/src/GDAL/OGRSimpleCurve.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSimpleCurve.hs
@@ -0,0 +1,7 @@
+module GDAL.OGRSimpleCurve
+       (OGRSimpleCurve(..), IOGRSimpleCurve, upcastOGRSimpleCurve,
+        downcastOGRSimpleCurve, oGRSimpleCurve_getPoints)
+       where
+import GDAL.OGRSimpleCurve.RawType
+import GDAL.OGRSimpleCurve.Interface
+import GDAL.OGRSimpleCurve.Implementation
diff --git a/src/GDAL/OGRSimpleCurve/Cast.hs b/src/GDAL/OGRSimpleCurve/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSimpleCurve/Cast.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRSimpleCurve.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRSimpleCurve.RawType
+import GDAL.OGRSimpleCurve.Interface
+
+instance (IOGRSimpleCurve a, FPtr a) =>
+         Castable (a) (Ptr RawOGRSimpleCurve)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRSimpleCurve) (Ptr RawOGRSimpleCurve)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRSimpleCurve/FFI.hsc b/src/GDAL/OGRSimpleCurve/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSimpleCurve/FFI.hsc
@@ -0,0 +1,157 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRSimpleCurve.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRSimpleCurve.RawType
+import GDAL.OGRSimpleCurve.RawType
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGREnvelope.RawType
+import GDAL.OGRPoint.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_getNumPoints"
+               c_ogrsimplecurve_getnumpoints :: Ptr RawOGRSimpleCurve -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_getPointIterator"
+               c_ogrsimplecurve_getpointiterator ::
+               Ptr RawOGRSimpleCurve -> IO (Ptr RawOGRPointIterator)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_getGeometryType"
+               c_ogrsimplecurve_getgeometrytype ::
+               Ptr RawOGRSimpleCurve -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_getEnvelope"
+               c_ogrsimplecurve_getenvelope ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Intersects"
+               c_ogrsimplecurve_intersects ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Equals"
+               c_ogrsimplecurve_equals ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Disjoint"
+               c_ogrsimplecurve_disjoint ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Touches"
+               c_ogrsimplecurve_touches ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Crosses"
+               c_ogrsimplecurve_crosses ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Within"
+               c_ogrsimplecurve_within ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Contains"
+               c_ogrsimplecurve_contains ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Overlaps"
+               c_ogrsimplecurve_overlaps ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Boundary"
+               c_ogrsimplecurve_boundary ::
+               Ptr RawOGRSimpleCurve -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Distance"
+               c_ogrsimplecurve_distance ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_ConvexHull"
+               c_ogrsimplecurve_convexhull ::
+               Ptr RawOGRSimpleCurve -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Buffer"
+               c_ogrsimplecurve_buffer ::
+               Ptr RawOGRSimpleCurve -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Intersection"
+               c_ogrsimplecurve_intersection ::
+               Ptr RawOGRSimpleCurve ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Union" c_ogrsimplecurve_union
+               ::
+               Ptr RawOGRSimpleCurve ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_UnionCascaded"
+               c_ogrsimplecurve_unioncascaded ::
+               Ptr RawOGRSimpleCurve -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Difference"
+               c_ogrsimplecurve_difference ::
+               Ptr RawOGRSimpleCurve ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_SymDifference"
+               c_ogrsimplecurve_symdifference ::
+               Ptr RawOGRSimpleCurve ->
+                 Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Centroid"
+               c_ogrsimplecurve_centroid ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Simplify"
+               c_ogrsimplecurve_simplify ::
+               Ptr RawOGRSimpleCurve -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_DelaunayTriangulation"
+               c_ogrsimplecurve_delaunaytriangulation ::
+               Ptr RawOGRSimpleCurve -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Polygonize"
+               c_ogrsimplecurve_polygonize ::
+               Ptr RawOGRSimpleCurve -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_Distance3D"
+               c_ogrsimplecurve_distance3d ::
+               Ptr RawOGRSimpleCurve -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_delete"
+               c_ogrsimplecurve_delete :: Ptr RawOGRSimpleCurve -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRSimpleCurve.h OGRSimpleCurve_oGRSimpleCurve_getPoints"
+               c_ogrsimplecurve_ogrsimplecurve_getpoints ::
+               Ptr RawOGRSimpleCurve ->
+                 Ptr () -> CInt -> Ptr () -> CInt -> Ptr () -> CInt -> IO ()
diff --git a/src/GDAL/OGRSimpleCurve/Implementation.hs b/src/GDAL/OGRSimpleCurve/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSimpleCurve/Implementation.hs
@@ -0,0 +1,90 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRSimpleCurve.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRSimpleCurve.RawType
+import GDAL.OGRSimpleCurve.FFI
+import GDAL.OGRSimpleCurve.Interface
+import GDAL.OGRSimpleCurve.Cast
+import GDAL.OGRSimpleCurve.RawType
+import GDAL.OGRSimpleCurve.Cast
+import GDAL.OGRSimpleCurve.Interface
+import GDAL.OGRPointIterator.RawType
+import GDAL.OGRPointIterator.Cast
+import GDAL.OGRPointIterator.Interface
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import GDAL.OGRCurve.RawType
+import GDAL.OGRCurve.Cast
+import GDAL.OGRCurve.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRSimpleCurve (OGRSimpleCurve) where
+
+instance () => IOGRCurve (OGRSimpleCurve) where
+        getNumPoints = xform0 c_ogrsimplecurve_getnumpoints
+        getPointIterator = xform0 c_ogrsimplecurve_getpointiterator
+
+instance () => IOGRGeometry (OGRSimpleCurve) where
+        getGeometryType = xform0 c_ogrsimplecurve_getgeometrytype
+        getEnvelope = xform1 c_ogrsimplecurve_getenvelope
+        intersects = xform1 c_ogrsimplecurve_intersects
+        equals = xform1 c_ogrsimplecurve_equals
+        disjoint = xform1 c_ogrsimplecurve_disjoint
+        touches = xform1 c_ogrsimplecurve_touches
+        crosses = xform1 c_ogrsimplecurve_crosses
+        within = xform1 c_ogrsimplecurve_within
+        contains = xform1 c_ogrsimplecurve_contains
+        overlaps = xform1 c_ogrsimplecurve_overlaps
+        boundary = xform0 c_ogrsimplecurve_boundary
+        distance = xform1 c_ogrsimplecurve_distance
+        convexHull = xform0 c_ogrsimplecurve_convexhull
+        buffer = xform2 c_ogrsimplecurve_buffer
+        intersection = xform1 c_ogrsimplecurve_intersection
+        union = xform1 c_ogrsimplecurve_union
+        unionCascaded = xform0 c_ogrsimplecurve_unioncascaded
+        difference = xform1 c_ogrsimplecurve_difference
+        symDifference = xform1 c_ogrsimplecurve_symdifference
+        centroid = xform1 c_ogrsimplecurve_centroid
+        simplify = xform1 c_ogrsimplecurve_simplify
+        delaunayTriangulation
+          = xform2 c_ogrsimplecurve_delaunaytriangulation
+        polygonize = xform0 c_ogrsimplecurve_polygonize
+        distance3D = xform1 c_ogrsimplecurve_distance3d
+
+instance () => IDeletable (OGRSimpleCurve) where
+        delete = xform0 c_ogrsimplecurve_delete
+
+oGRSimpleCurve_getPoints ::
+                           () =>
+                           OGRSimpleCurve ->
+                             Ptr () -> CInt -> Ptr () -> CInt -> Ptr () -> CInt -> IO ()
+oGRSimpleCurve_getPoints
+  = xform6 c_ogrsimplecurve_ogrsimplecurve_getpoints
diff --git a/src/GDAL/OGRSimpleCurve/Interface.hs b/src/GDAL/OGRSimpleCurve/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSimpleCurve/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRSimpleCurve.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRSimpleCurve.RawType
+import GDAL.OGRCurve.Interface
+
+class (IOGRCurve a) => IOGRSimpleCurve a where
+
+upcastOGRSimpleCurve ::
+                     forall a . (FPtr a, IOGRSimpleCurve a) => a -> OGRSimpleCurve
+upcastOGRSimpleCurve h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRSimpleCurve = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRSimpleCurve ::
+                       forall a . (FPtr a, IOGRSimpleCurve a) => OGRSimpleCurve -> a
+downcastOGRSimpleCurve h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRSimpleCurve/RawType.hs b/src/GDAL/OGRSimpleCurve/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSimpleCurve/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRSimpleCurve.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRSimpleCurve
+
+newtype OGRSimpleCurve = OGRSimpleCurve (Ptr RawOGRSimpleCurve)
+                           deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRSimpleCurve) where
+        type Raw OGRSimpleCurve = RawOGRSimpleCurve
+        get_fptr (OGRSimpleCurve ptr) = ptr
+        cast_fptr_to_obj = OGRSimpleCurve
diff --git a/src/GDAL/OGRSurface.hs b/src/GDAL/OGRSurface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSurface.hs
@@ -0,0 +1,6 @@
+module GDAL.OGRSurface
+       (OGRSurface(..), IOGRSurface, upcastOGRSurface, downcastOGRSurface)
+       where
+import GDAL.OGRSurface.RawType
+import GDAL.OGRSurface.Interface
+import GDAL.OGRSurface.Implementation
diff --git a/src/GDAL/OGRSurface/Cast.hs b/src/GDAL/OGRSurface/Cast.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSurface/Cast.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
+  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
+  #-}
+module GDAL.OGRSurface.Cast where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import System.IO.Unsafe
+import GDAL.OGRSurface.RawType
+import GDAL.OGRSurface.Interface
+
+instance (IOGRSurface a, FPtr a) =>
+         Castable (a) (Ptr RawOGRSurface)
+         where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
+
+instance () => Castable (OGRSurface) (Ptr RawOGRSurface) where
+        cast x f = f (castPtr (get_fptr x))
+        uncast x f = f (cast_fptr_to_obj (castPtr x))
diff --git a/src/GDAL/OGRSurface/FFI.hsc b/src/GDAL/OGRSurface/FFI.hsc
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSurface/FFI.hsc
@@ -0,0 +1,118 @@
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.OGRSurface.FFI where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import GDAL.OGRSurface.RawType
+import GDAL.OGRSurface.RawType
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGREnvelope.RawType
+import GDAL.OGRPoint.RawType
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_getGeometryType"
+               c_ogrsurface_getgeometrytype :: Ptr RawOGRSurface -> IO CUInt
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_getEnvelope" c_ogrsurface_getenvelope
+               :: Ptr RawOGRSurface -> Ptr RawOGREnvelope -> IO ()
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Intersects" c_ogrsurface_intersects
+               :: Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Equals" c_ogrsurface_equals ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Disjoint" c_ogrsurface_disjoint ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Touches" c_ogrsurface_touches ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Crosses" c_ogrsurface_crosses ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Within" c_ogrsurface_within ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Contains" c_ogrsurface_contains ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Overlaps" c_ogrsurface_overlaps ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO CBool
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Boundary" c_ogrsurface_boundary ::
+               Ptr RawOGRSurface -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Distance" c_ogrsurface_distance ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_ConvexHull" c_ogrsurface_convexhull
+               :: Ptr RawOGRSurface -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Buffer" c_ogrsurface_buffer ::
+               Ptr RawOGRSurface -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Intersection"
+               c_ogrsurface_intersection ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Union" c_ogrsurface_union ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_UnionCascaded"
+               c_ogrsurface_unioncascaded ::
+               Ptr RawOGRSurface -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Difference" c_ogrsurface_difference
+               ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_SymDifference"
+               c_ogrsurface_symdifference ::
+               Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Centroid" c_ogrsurface_centroid ::
+               Ptr RawOGRSurface -> Ptr RawOGRPoint -> IO CInt
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Simplify" c_ogrsurface_simplify ::
+               Ptr RawOGRSurface -> CDouble -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_DelaunayTriangulation"
+               c_ogrsurface_delaunaytriangulation ::
+               Ptr RawOGRSurface -> CDouble -> CInt -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Polygonize" c_ogrsurface_polygonize
+               :: Ptr RawOGRSurface -> IO (Ptr RawOGRGeometry)
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_Distance3D" c_ogrsurface_distance3d
+               :: Ptr RawOGRSurface -> Ptr RawOGRGeometry -> IO CDouble
+
+foreign import ccall interruptible
+               "HGDALOGRSurface.h OGRSurface_delete" c_ogrsurface_delete ::
+               Ptr RawOGRSurface -> IO ()
diff --git a/src/GDAL/OGRSurface/Implementation.hs b/src/GDAL/OGRSurface/Implementation.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSurface/Implementation.hs
@@ -0,0 +1,72 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, IncoherentInstances,
+  MultiParamTypeClasses, OverlappingInstances, TemplateHaskell,
+  TypeFamilies, TypeSynonymInstances #-}
+module GDAL.OGRSurface.Implementation where
+import Data.Monoid
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import System.IO.Unsafe
+import FFICXX.Runtime.Cast
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
+import GDAL.OGRSurface.RawType
+import GDAL.OGRSurface.FFI
+import GDAL.OGRSurface.Interface
+import GDAL.OGRSurface.Cast
+import GDAL.OGRSurface.RawType
+import GDAL.OGRSurface.Cast
+import GDAL.OGRSurface.Interface
+import GDAL.OGRPolygon.RawType
+import GDAL.OGRPolygon.Cast
+import GDAL.OGRPolygon.Interface
+import GDAL.OGRMultiPolygon.RawType
+import GDAL.OGRMultiPolygon.Cast
+import GDAL.OGRMultiPolygon.Interface
+import GDAL.OGREnvelope.RawType
+import GDAL.OGREnvelope.Cast
+import GDAL.OGREnvelope.Interface
+import GDAL.OGRPoint.RawType
+import GDAL.OGRPoint.Cast
+import GDAL.OGRPoint.Interface
+import GDAL.OGRGeometry.RawType
+import GDAL.OGRGeometry.Cast
+import GDAL.OGRGeometry.Interface
+import STD.Deletable.RawType
+import STD.Deletable.Cast
+import STD.Deletable.Interface
+
+instance () => IOGRSurface (OGRSurface) where
+
+instance () => IOGRGeometry (OGRSurface) where
+        getGeometryType = xform0 c_ogrsurface_getgeometrytype
+        getEnvelope = xform1 c_ogrsurface_getenvelope
+        intersects = xform1 c_ogrsurface_intersects
+        equals = xform1 c_ogrsurface_equals
+        disjoint = xform1 c_ogrsurface_disjoint
+        touches = xform1 c_ogrsurface_touches
+        crosses = xform1 c_ogrsurface_crosses
+        within = xform1 c_ogrsurface_within
+        contains = xform1 c_ogrsurface_contains
+        overlaps = xform1 c_ogrsurface_overlaps
+        boundary = xform0 c_ogrsurface_boundary
+        distance = xform1 c_ogrsurface_distance
+        convexHull = xform0 c_ogrsurface_convexhull
+        buffer = xform2 c_ogrsurface_buffer
+        intersection = xform1 c_ogrsurface_intersection
+        union = xform1 c_ogrsurface_union
+        unionCascaded = xform0 c_ogrsurface_unioncascaded
+        difference = xform1 c_ogrsurface_difference
+        symDifference = xform1 c_ogrsurface_symdifference
+        centroid = xform1 c_ogrsurface_centroid
+        simplify = xform1 c_ogrsurface_simplify
+        delaunayTriangulation = xform2 c_ogrsurface_delaunaytriangulation
+        polygonize = xform0 c_ogrsurface_polygonize
+        distance3D = xform1 c_ogrsurface_distance3d
+
+instance () => IDeletable (OGRSurface) where
+        delete = xform0 c_ogrsurface_delete
diff --git a/src/GDAL/OGRSurface/Interface.hs b/src/GDAL/OGRSurface/Interface.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSurface/Interface.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
+  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
+  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
+  TypeSynonymInstances #-}
+module GDAL.OGRSurface.Interface where
+import Data.Word
+import Data.Int
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.OGRSurface.RawType
+import GDAL.OGRGeometry.Interface
+
+class (IOGRGeometry a) => IOGRSurface a where
+
+upcastOGRSurface ::
+                 forall a . (FPtr a, IOGRSurface a) => a -> OGRSurface
+upcastOGRSurface h
+  = let fh = get_fptr h
+        fh2 :: Ptr RawOGRSurface = castPtr fh
+      in cast_fptr_to_obj fh2
+
+downcastOGRSurface ::
+                   forall a . (FPtr a, IOGRSurface a) => OGRSurface -> a
+downcastOGRSurface h
+  = let fh = get_fptr h
+        fh2 = castPtr fh
+      in cast_fptr_to_obj fh2
diff --git a/src/GDAL/OGRSurface/RawType.hs b/src/GDAL/OGRSurface/RawType.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/OGRSurface/RawType.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE ForeignFunctionInterface, TypeFamilies,
+  MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances,
+  EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}
+module GDAL.OGRSurface.RawType where
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+
+data RawOGRSurface
+
+newtype OGRSurface = OGRSurface (Ptr RawOGRSurface)
+                       deriving (Eq, Ord, Show)
+
+instance () => FPtr (OGRSurface) where
+        type Raw OGRSurface = RawOGRSurface
+        get_fptr (OGRSurface ptr) = ptr
+        cast_fptr_to_obj = OGRSurface
diff --git a/src/GDAL/Ordinary.hs b/src/GDAL/Ordinary.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/Ordinary.hs
@@ -0,0 +1,30 @@
+{-# LANGUAGE FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, InterruptibleFFI #-}
+module GDAL.Ordinary (gDALAllRegister, gDALOpenEx) where
+import Foreign.C
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
+import GDAL.GDALDataset.RawType
+import GDAL.GDALDataset.Cast
+import GDAL.GDALDataset.Interface
+
+foreign import ccall interruptible
+               "hgdalTopLevel.h TopLevel_GDALAllRegister" c_gdalallregister ::
+               IO ()
+
+foreign import ccall interruptible
+               "hgdalTopLevel.h TopLevel_GDALOpenEx" c_gdalopenex ::
+               CString ->
+                 CUInt ->
+                   Ptr CString ->
+                     Ptr CString -> Ptr CString -> IO (Ptr RawGDALDataset)
+
+gDALAllRegister :: () => IO ()
+gDALAllRegister = xformnull c_gdalallregister
+
+gDALOpenEx ::
+             (Castable c0 CString) =>
+             c0 ->
+               CUInt ->
+                 Ptr CString -> Ptr CString -> Ptr CString -> IO GDALDataset
+gDALOpenEx = xform4 c_gdalopenex
diff --git a/src/GDAL/TH.hs b/src/GDAL/TH.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/TH.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE FlexibleContexts, FlexibleInstances,
+  ForeignFunctionInterface, InterruptibleFFI, TemplateHaskell #-}
+module GDAL.TH () where
+import Data.Char
+import Data.List
+import Data.Monoid
+import Foreign.C.Types
+import Foreign.Ptr
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+import FFICXX.Runtime.CodeGen.Cxx
+import FFICXX.Runtime.TH
diff --git a/src/GDAL/Template.hs b/src/GDAL/Template.hs
new file mode 100644
--- /dev/null
+++ b/src/GDAL/Template.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE EmptyDataDecls, FlexibleInstances,
+  ForeignFunctionInterface, InterruptibleFFI, MultiParamTypeClasses,
+  TypeFamilies #-}
+module GDAL.Template () where
+import Foreign.C.Types
+import Foreign.Ptr
+import FFICXX.Runtime.Cast
