text:
# Contents of this file is generated. Do not edit by hand!

const GEOSMessageHandler = Ptr{Void}
const GEOSGeometry = Ptr{Void}
const GEOSPreparedGeometry = Ptr{Void}
const GEOSCoordSequence = Ptr{Void}
const GEOSSTRtree = Ptr{Void}
const GEOSBufferParams = Ptr{Void}
const GEOSContextHandle_t = Ptr{Void}
const GEOSQueryCallback = Ptr{Void}
const GEOSInterruptCallback = Ptr{Void}
const GEOSWKTReader = Ptr{Void}
const GEOSWKTWriter = Ptr{Void}
const GEOSWKBReader = Ptr{Void}
const GEOSWKBWriter = Ptr{Void}

const GEOSGeom = Ptr{GEOSGeometry}
const GEOSCoordSeq = Ptr{GEOSCoordSequence}

const GEOS_POINT=0
const GEOS_LINESTRING=1
const GEOS_LINEARRING=2
const GEOS_POLYGON=3
const GEOS_MULTIPOINT=4
const GEOS_MULTILINESTRING=5
const GEOS_MULTIPOLYGON=6
const GEOS_GEOMETRYCOLLECTION=7

const GEOS_WKB_XDR = 0
const GEOS_WKB_NDR = 1

function initGEOS(notice_function::GEOSMessageHandler,error_function::GEOSMessageHandler)
    ccall((:initGEOS,libgeos),Void,(GEOSMessageHandler,GEOSMessageHandler),notice_function,error_function)
end

function finishGEOS()
    ccall((:finishGEOS,libgeos),Void,())
end

function GEOS_interruptRegisterCallback(cb::Ptr{GEOSInterruptCallback})
    ccall((:GEOS_interruptRegisterCallback,libgeos),Ptr{GEOSInterruptCallback},(Ptr{GEOSInterruptCallback},),cb)
end

function initGEOS_r(notice_function::GEOSMessageHandler,error_function::GEOSMessageHandler)
    ccall((:initGEOS_r,libgeos),GEOSContextHandle_t,(GEOSMessageHandler,GEOSMessageHandler),notice_function,error_function)
end

function finishGEOS_r(handle::GEOSContextHandle_t)
    ccall((:finishGEOS_r,libgeos),Void,(GEOSContextHandle_t,),handle)
end

function GEOS_init_r()
    ccall((:GEOS_init_r,libgeos),GEOSContextHandle_t,())
end

function GEOS_finish_r(handle::GEOSContextHandle_t)
    ccall((:GEOS_finish_r,libgeos),Void,(GEOSContextHandle_t,),handle)
end

function GEOSContext_setNoticeHandler_r(extHandle::GEOSContextHandle_t,nf::GEOSMessageHandler)
    ccall((:GEOSContext_setNoticeHandler_r,libgeos),GEOSMessageHandler,(GEOSContextHandle_t,GEOSMessageHandler),extHandle,nf)
end

function GEOSContext_setErrorHandler_r(extHandle::GEOSContextHandle_t,ef::GEOSMessageHandler)
    ccall((:GEOSContext_setErrorHandler_r,libgeos),GEOSMessageHandler,(GEOSContextHandle_t,GEOSMessageHandler),extHandle,ef)
end

function GEOSGeomFromWKT(wkt::String)
    ccall((:GEOSGeomFromWKT,libgeos),Ptr{GEOSGeometry},(Ptr{UInt8},),wkt)
end

function GEOSGeomToWKT(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomToWKT,libgeos),Ptr{UInt8},(Ptr{GEOSGeometry},),g)
end

function GEOSGeomFromWKT_r(handle::GEOSContextHandle_t,wkt::String)
    ccall((:GEOSGeomFromWKT_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{UInt8}),handle,wkt)
end

function GEOSGeomToWKT_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomToWKT_r,libgeos),Ptr{UInt8},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOS_setWKBOutputDims(newDims::Integer)
    ccall((:GEOS_setWKBOutputDims,libgeos),Cint,(Cint,),newDims)
end

function GEOS_getWKBOutputDims_r(handle::GEOSContextHandle_t)
    ccall((:GEOS_getWKBOutputDims_r,libgeos),Cint,(GEOSContextHandle_t,),handle)
end

function GEOS_setWKBOutputDims_r(handle::GEOSContextHandle_t,newDims::Integer)
    ccall((:GEOS_setWKBOutputDims_r,libgeos),Cint,(GEOSContextHandle_t,Cint),handle,newDims)
end

function GEOS_setWKBByteOrder(byteOrder::Integer)
    ccall((:GEOS_setWKBByteOrder,libgeos),Cint,(Cint,),byteOrder)
end

function GEOSGeomFromWKB_buf(wkb::Ptr{Cuchar},size::Integer)
    ccall((:GEOSGeomFromWKB_buf,libgeos),Ptr{GEOSGeometry},(Ptr{Cuchar},Csize_t),wkb,size)
end

function GEOSGeomToWKB_buf(g::Ptr{GEOSGeometry},size::Ptr{Csize_t})
    ccall((:GEOSGeomToWKB_buf,libgeos),Ptr{Cuchar},(Ptr{GEOSGeometry},Ptr{Csize_t}),g,size)
end

function GEOSGeomFromHEX_buf(hex::Ptr{Cuchar},size::Integer)
    ccall((:GEOSGeomFromHEX_buf,libgeos),Ptr{GEOSGeometry},(Ptr{Cuchar},Csize_t),hex,size)
end

function GEOSGeomToHEX_buf(g::Ptr{GEOSGeometry},size::Ptr{Csize_t})
    ccall((:GEOSGeomToHEX_buf,libgeos),Ptr{Cuchar},(Ptr{GEOSGeometry},Ptr{Csize_t}),g,size)
end

function GEOS_getWKBByteOrder_r(handle::GEOSContextHandle_t)
    ccall((:GEOS_getWKBByteOrder_r,libgeos),Cint,(GEOSContextHandle_t,),handle)
end

function GEOS_setWKBByteOrder_r(handle::GEOSContextHandle_t,byteOrder::Integer)
    ccall((:GEOS_setWKBByteOrder_r,libgeos),Cint,(GEOSContextHandle_t,Cint),handle,byteOrder)
end

function GEOSGeomFromWKB_buf_r(handle::GEOSContextHandle_t,wkb::Ptr{Cuchar},size::Integer)
    ccall((:GEOSGeomFromWKB_buf_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{Cuchar},Csize_t),handle,wkb,size)
end

function GEOSGeomToWKB_buf_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},size::Ptr{Csize_t})
    ccall((:GEOSGeomToWKB_buf_r,libgeos),Ptr{Cuchar},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{Csize_t}),handle,g,size)
end

function GEOSGeomFromHEX_buf_r(handle::GEOSContextHandle_t,hex::Ptr{Cuchar},size::Integer)
    ccall((:GEOSGeomFromHEX_buf_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{Cuchar},Csize_t),handle,hex,size)
end

function GEOSGeomToHEX_buf_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},size::Ptr{Csize_t})
    ccall((:GEOSGeomToHEX_buf_r,libgeos),Ptr{Cuchar},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{Csize_t}),handle,g,size)
end

function GEOSCoordSeq_create(size::Integer,dims::Integer)
    ccall((:GEOSCoordSeq_create,libgeos),Ptr{GEOSCoordSequence},(UInt32,UInt32),size,dims)
end

function GEOSCoordSeq_create_r(handle::GEOSContextHandle_t,size::Integer,dims::Integer)
    ccall((:GEOSCoordSeq_create_r,libgeos),Ptr{GEOSCoordSequence},(GEOSContextHandle_t,UInt32,UInt32),handle,size,dims)
end

function GEOSCoordSeq_clone(s::Ptr{GEOSCoordSequence})
    ccall((:GEOSCoordSeq_clone,libgeos),Ptr{GEOSCoordSequence},(Ptr{GEOSCoordSequence},),s)
end

function GEOSCoordSeq_clone_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence})
    ccall((:GEOSCoordSeq_clone_r,libgeos),Ptr{GEOSCoordSequence},(GEOSContextHandle_t,Ptr{GEOSCoordSequence}),handle,s)
end

function GEOSCoordSeq_destroy(s::Ptr{GEOSCoordSequence})
    ccall((:GEOSCoordSeq_destroy,libgeos),Void,(Ptr{GEOSCoordSequence},),s)
end

function GEOSCoordSeq_destroy_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence})
    ccall((:GEOSCoordSeq_destroy_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSCoordSequence}),handle,s)
end

function GEOSCoordSeq_setX(s::Ptr{GEOSCoordSequence},idx::Integer,val::Real)
    ccall((:GEOSCoordSeq_setX,libgeos),Cint,(Ptr{GEOSCoordSequence},UInt32,Cdouble),s,idx,val)
end

function GEOSCoordSeq_setY(s::Ptr{GEOSCoordSequence},idx::Integer,val::Real)
    ccall((:GEOSCoordSeq_setY,libgeos),Cint,(Ptr{GEOSCoordSequence},UInt32,Cdouble),s,idx,val)
end

function GEOSCoordSeq_setZ(s::Ptr{GEOSCoordSequence},idx::Integer,val::Real)
    ccall((:GEOSCoordSeq_setZ,libgeos),Cint,(Ptr{GEOSCoordSequence},UInt32,Cdouble),s,idx,val)
end

function GEOSCoordSeq_setOrdinate(s::Ptr{GEOSCoordSequence},idx::Integer,dim::Integer,val::Real)
    ccall((:GEOSCoordSeq_setOrdinate,libgeos),Cint,(Ptr{GEOSCoordSequence},UInt32,UInt32,Cdouble),s,idx,dim,val)
end

function GEOSCoordSeq_setX_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence},idx::Integer,val::Real)
    ccall((:GEOSCoordSeq_setX_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSCoordSequence},UInt32,Cdouble),handle,s,idx,val)
end

function GEOSCoordSeq_setY_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence},idx::Integer,val::Real)
    ccall((:GEOSCoordSeq_setY_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSCoordSequence},UInt32,Cdouble),handle,s,idx,val)
end

function GEOSCoordSeq_setZ_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence},idx::Integer,val::Real)
    ccall((:GEOSCoordSeq_setZ_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSCoordSequence},UInt32,Cdouble),handle,s,idx,val)
end

function GEOSCoordSeq_setOrdinate_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence},idx::Integer,dim::Integer,val::Real)
    ccall((:GEOSCoordSeq_setOrdinate_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSCoordSequence},UInt32,UInt32,Cdouble),handle,s,idx,dim,val)
end

function GEOSCoordSeq_getX(s::Ptr{GEOSCoordSequence},idx::Integer,val::Ptr{Cdouble})
    ccall((:GEOSCoordSeq_getX,libgeos),Cint,(Ptr{GEOSCoordSequence},UInt32,Ptr{Cdouble}),s,idx,val)
end

function GEOSCoordSeq_getY(s::Ptr{GEOSCoordSequence},idx::Integer,val::Ptr{Cdouble})
    ccall((:GEOSCoordSeq_getY,libgeos),Cint,(Ptr{GEOSCoordSequence},UInt32,Ptr{Cdouble}),s,idx,val)
end

function GEOSCoordSeq_getZ(s::Ptr{GEOSCoordSequence},idx::Integer,val::Ptr{Cdouble})
    ccall((:GEOSCoordSeq_getZ,libgeos),Cint,(Ptr{GEOSCoordSequence},UInt32,Ptr{Cdouble}),s,idx,val)
end

function GEOSCoordSeq_getOrdinate(s::Ptr{GEOSCoordSequence},idx::Integer,dim::Integer,val::Ptr{Cdouble})
    ccall((:GEOSCoordSeq_getOrdinate,libgeos),Cint,(Ptr{GEOSCoordSequence},UInt32,UInt32,Ptr{Cdouble}),s,idx,dim,val)
end

function GEOSCoordSeq_getX_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence},idx::Integer,val::Ptr{Cdouble})
    ccall((:GEOSCoordSeq_getX_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSCoordSequence},UInt32,Ptr{Cdouble}),handle,s,idx,val)
end

function GEOSCoordSeq_getY_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence},idx::Integer,val::Ptr{Cdouble})
    ccall((:GEOSCoordSeq_getY_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSCoordSequence},UInt32,Ptr{Cdouble}),handle,s,idx,val)
end

function GEOSCoordSeq_getZ_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence},idx::Integer,val::Ptr{Cdouble})
    ccall((:GEOSCoordSeq_getZ_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSCoordSequence},UInt32,Ptr{Cdouble}),handle,s,idx,val)
end

function GEOSCoordSeq_getOrdinate_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence},idx::Integer,dim::Integer,val::Ptr{Cdouble})
    ccall((:GEOSCoordSeq_getOrdinate_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSCoordSequence},UInt32,UInt32,Ptr{Cdouble}),handle,s,idx,dim,val)
end

function GEOSCoordSeq_getSize(s::Ptr{GEOSCoordSequence},size::Ptr{UInt32})
    ccall((:GEOSCoordSeq_getSize,libgeos),Cint,(Ptr{GEOSCoordSequence},Ptr{UInt32}),s,size)
end

function GEOSCoordSeq_getDimensions(s::Ptr{GEOSCoordSequence},dims::Ptr{UInt32})
    ccall((:GEOSCoordSeq_getDimensions,libgeos),Cint,(Ptr{GEOSCoordSequence},Ptr{UInt32}),s,dims)
end

function GEOSCoordSeq_getSize_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence},size::Ptr{UInt32})
    ccall((:GEOSCoordSeq_getSize_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSCoordSequence},Ptr{UInt32}),handle,s,size)
end

function GEOSCoordSeq_getDimensions_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence},dims::Ptr{UInt32})
    ccall((:GEOSCoordSeq_getDimensions_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSCoordSequence},Ptr{UInt32}),handle,s,dims)
end

function GEOSProject(g::Ptr{GEOSGeometry},p::Ptr{GEOSGeometry})
    ccall((:GEOSProject,libgeos),Cdouble,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g,p)
end

function GEOSProject_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},p::Ptr{GEOSGeometry})
    ccall((:GEOSProject_r,libgeos),Cdouble,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g,p)
end

function GEOSInterpolate(g::Ptr{GEOSGeometry},d::Real)
    ccall((:GEOSInterpolate,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cdouble),g,d)
end

function GEOSInterpolate_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},d::Real)
    ccall((:GEOSInterpolate_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cdouble),handle,g,d)
end

function GEOSProjectNormalized(g::Ptr{GEOSGeometry},p::Ptr{GEOSGeometry})
    ccall((:GEOSProjectNormalized,libgeos),Cdouble,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g,p)
end

function GEOSProjectNormalized_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},p::Ptr{GEOSGeometry})
    ccall((:GEOSProjectNormalized_r,libgeos),Cdouble,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g,p)
end

function GEOSInterpolateNormalized(g::Ptr{GEOSGeometry},d::Real)
    ccall((:GEOSInterpolateNormalized,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cdouble),g,d)
end

function GEOSInterpolateNormalized_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},d::Real)
    ccall((:GEOSInterpolateNormalized_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cdouble),handle,g,d)
end

function GEOSBuffer(g::Ptr{GEOSGeometry},width::Real,quadsegs::Integer)
    ccall((:GEOSBuffer,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cdouble,Cint),g,width,quadsegs)
end

function GEOSBuffer_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},width::Real,quadsegs::Integer)
    ccall((:GEOSBuffer_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cdouble,Cint),handle,g,width,quadsegs)
end

function GEOSBufferParams_create_r(handle::GEOSContextHandle_t)
    ccall((:GEOSBufferParams_create_r,libgeos),Ptr{GEOSBufferParams},(GEOSContextHandle_t,),handle)
end

function GEOSBufferParams_destroy(parms::Ptr{GEOSBufferParams})
    ccall((:GEOSBufferParams_destroy,libgeos),Void,(Ptr{GEOSBufferParams},),parms)
end

function GEOSBufferParams_destroy_r(handle::GEOSContextHandle_t,parms::Ptr{GEOSBufferParams})
    ccall((:GEOSBufferParams_destroy_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSBufferParams}),handle,parms)
end

function GEOSBufferParams_setEndCapStyle(p::Ptr{GEOSBufferParams},style::Integer)
    ccall((:GEOSBufferParams_setEndCapStyle,libgeos),Cint,(Ptr{GEOSBufferParams},Cint),p,style)
end

function GEOSBufferParams_setEndCapStyle_r(handle::GEOSContextHandle_t,p::Ptr{GEOSBufferParams},style::Integer)
    ccall((:GEOSBufferParams_setEndCapStyle_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSBufferParams},Cint),handle,p,style)
end

function GEOSBufferParams_setJoinStyle(p::Ptr{GEOSBufferParams},joinStyle::Integer)
    ccall((:GEOSBufferParams_setJoinStyle,libgeos),Cint,(Ptr{GEOSBufferParams},Cint),p,joinStyle)
end

function GEOSBufferParams_setJoinStyle_r(handle::GEOSContextHandle_t,p::Ptr{GEOSBufferParams},joinStyle::Integer)
    ccall((:GEOSBufferParams_setJoinStyle_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSBufferParams},Cint),handle,p,joinStyle)
end

function GEOSBufferParams_setMitreLimit(p::Ptr{GEOSBufferParams},mitreLimit::Real)
    ccall((:GEOSBufferParams_setMitreLimit,libgeos),Cint,(Ptr{GEOSBufferParams},Cdouble),p,mitreLimit)
end

function GEOSBufferParams_setMitreLimit_r(handle::GEOSContextHandle_t,p::Ptr{GEOSBufferParams},mitreLimit::Real)
    ccall((:GEOSBufferParams_setMitreLimit_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSBufferParams},Cdouble),handle,p,mitreLimit)
end

function GEOSBufferParams_setQuadrantSegments(p::Ptr{GEOSBufferParams},quadSegs::Integer)
    ccall((:GEOSBufferParams_setQuadrantSegments,libgeos),Cint,(Ptr{GEOSBufferParams},Cint),p,quadSegs)
end

function GEOSBufferParams_setQuadrantSegments_r(handle::GEOSContextHandle_t,p::Ptr{GEOSBufferParams},quadSegs::Integer)
    ccall((:GEOSBufferParams_setQuadrantSegments_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSBufferParams},Cint),handle,p,quadSegs)
end

function GEOSBufferParams_setSingleSided(p::Ptr{GEOSBufferParams},singleSided::Integer)
    ccall((:GEOSBufferParams_setSingleSided,libgeos),Cint,(Ptr{GEOSBufferParams},Cint),p,singleSided)
end

function GEOSBufferParams_setSingleSided_r(handle::GEOSContextHandle_t,p::Ptr{GEOSBufferParams},singleSided::Integer)
    ccall((:GEOSBufferParams_setSingleSided_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSBufferParams},Cint),handle,p,singleSided)
end

function GEOSBufferWithParams(g::Ptr{GEOSGeometry},p::Ptr{GEOSBufferParams},width::Real)
    ccall((:GEOSBufferWithParams,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Ptr{GEOSBufferParams},Cdouble),g,p,width)
end

function GEOSBufferWithParams_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},p::Ptr{GEOSBufferParams},width::Real)
    ccall((:GEOSBufferWithParams_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSBufferParams},Cdouble),handle,g,p,width)
end

function GEOSBufferWithStyle(g::Ptr{GEOSGeometry},width::Real,quadsegs::Integer,endCapStyle::Integer,joinStyle::Integer,mitreLimit::Real)
    ccall((:GEOSBufferWithStyle,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cdouble,Cint,Cint,Cint,Cdouble),g,width,quadsegs,endCapStyle,joinStyle,mitreLimit)
end

function GEOSBufferWithStyle_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},width::Real,quadsegs::Integer,endCapStyle::Integer,joinStyle::Integer,mitreLimit::Real)
    ccall((:GEOSBufferWithStyle_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cdouble,Cint,Cint,Cint,Cdouble),handle,g,width,quadsegs,endCapStyle,joinStyle,mitreLimit)
end

function GEOSSingleSidedBuffer(g::Ptr{GEOSGeometry},width::Real,quadsegs::Integer,joinStyle::Integer,mitreLimit::Real,leftSide::Integer)
    ccall((:GEOSSingleSidedBuffer,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cdouble,Cint,Cint,Cdouble,Cint),g,width,quadsegs,joinStyle,mitreLimit,leftSide)
end

function GEOSSingleSidedBuffer_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},width::Real,quadsegs::Integer,joinStyle::Integer,mitreLimit::Real,leftSide::Integer)
    ccall((:GEOSSingleSidedBuffer_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cdouble,Cint,Cint,Cdouble,Cint),handle,g,width,quadsegs,joinStyle,mitreLimit,leftSide)
end

function GEOSOffsetCurve(g::Ptr{GEOSGeometry},width::Real,quadsegs::Integer,joinStyle::Integer,mitreLimit::Real)
    ccall((:GEOSOffsetCurve,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cdouble,Cint,Cint,Cdouble),g,width,quadsegs,joinStyle,mitreLimit)
end

function GEOSOffsetCurve_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},width::Real,quadsegs::Integer,joinStyle::Integer,mitreLimit::Real)
    ccall((:GEOSOffsetCurve_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cdouble,Cint,Cint,Cdouble),handle,g,width,quadsegs,joinStyle,mitreLimit)
end

function GEOSGeom_createPoint(s::Ptr{GEOSCoordSequence})
    ccall((:GEOSGeom_createPoint,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSCoordSequence},),s)
end

function GEOSGeom_createLinearRing(s::Ptr{GEOSCoordSequence})
    ccall((:GEOSGeom_createLinearRing,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSCoordSequence},),s)
end

function GEOSGeom_createLineString(s::Ptr{GEOSCoordSequence})
    ccall((:GEOSGeom_createLineString,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSCoordSequence},),s)
end

function GEOSGeom_createPoint_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence})
    ccall((:GEOSGeom_createPoint_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSCoordSequence}),handle,s)
end

function GEOSGeom_createEmptyPoint_r(handle::GEOSContextHandle_t)
    ccall((:GEOSGeom_createEmptyPoint_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,),handle)
end

function GEOSGeom_createLinearRing_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence})
    ccall((:GEOSGeom_createLinearRing_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSCoordSequence}),handle,s)
end

function GEOSGeom_createLineString_r(handle::GEOSContextHandle_t,s::Ptr{GEOSCoordSequence})
    ccall((:GEOSGeom_createLineString_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSCoordSequence}),handle,s)
end

function GEOSGeom_createEmptyLineString_r(handle::GEOSContextHandle_t)
    ccall((:GEOSGeom_createEmptyLineString_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,),handle)
end

function GEOSGeom_createPolygon(shell::Ptr{GEOSGeometry},holes::Ptr{Ptr{GEOSGeometry}},nholes::Integer)
    ccall((:GEOSGeom_createPolygon,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Ptr{Ptr{GEOSGeometry}},UInt32),shell,holes,nholes)
end

function GEOSGeom_createCollection(_type::Integer,geoms::Ptr{Ptr{GEOSGeometry}},ngeoms::Integer)
    ccall((:GEOSGeom_createCollection,libgeos),Ptr{GEOSGeometry},(Cint,Ptr{Ptr{GEOSGeometry}},UInt32),_type,geoms,ngeoms)
end

function GEOSGeom_createEmptyCollection(_type::Integer)
    ccall((:GEOSGeom_createEmptyCollection,libgeos),Ptr{GEOSGeometry},(Cint,),_type)
end

function GEOSGeom_createEmptyPolygon_r(handle::GEOSContextHandle_t)
    ccall((:GEOSGeom_createEmptyPolygon_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,),handle)
end

function GEOSGeom_createPolygon_r(handle::GEOSContextHandle_t,shell::Ptr{GEOSGeometry},holes::Ptr{Ptr{GEOSGeometry}},nholes::Integer)
    ccall((:GEOSGeom_createPolygon_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{Ptr{GEOSGeometry}},UInt32),handle,shell,holes,nholes)
end

function GEOSGeom_createCollection_r(handle::GEOSContextHandle_t,_type::Integer,geoms::Ptr{Ptr{GEOSGeometry}},ngeoms::Integer)
    ccall((:GEOSGeom_createCollection_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Cint,Ptr{Ptr{GEOSGeometry}},UInt32),handle,_type,geoms,ngeoms)
end

function GEOSGeom_createEmptyCollection_r(handle::GEOSContextHandle_t,_type::Integer)
    ccall((:GEOSGeom_createEmptyCollection_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Cint),handle,_type)
end

function GEOSGeom_clone(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_clone,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSGeom_clone_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_clone_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGeom_destroy(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_destroy,libgeos),Void,(Ptr{GEOSGeometry},),g)
end

function GEOSGeom_destroy_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_destroy_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSEnvelope(g::Ptr{GEOSGeometry})
    ccall((:GEOSEnvelope,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSIntersection(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSIntersection,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSConvexHull(g::Ptr{GEOSGeometry})
    ccall((:GEOSConvexHull,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSDifference(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSDifference,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSSymDifference(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSSymDifference,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSBoundary(g::Ptr{GEOSGeometry})
    ccall((:GEOSBoundary,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSUnion(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSUnion,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSUnaryUnion(g::Ptr{GEOSGeometry})
    ccall((:GEOSUnaryUnion,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSUnionCascaded(g::Ptr{GEOSGeometry})
    ccall((:GEOSUnionCascaded,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSPointOnSurface(g::Ptr{GEOSGeometry})
    ccall((:GEOSPointOnSurface,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSGetCentroid(g::Ptr{GEOSGeometry})
    ccall((:GEOSGetCentroid,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSNode(g::Ptr{GEOSGeometry})
    ccall((:GEOSNode,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSEnvelope_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSEnvelope_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSIntersection_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSIntersection_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSConvexHull_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSConvexHull_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSDifference_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSDifference_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSSymDifference_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSSymDifference_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSBoundary_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSBoundary_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSUnion_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSUnion_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSUnaryUnion_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSUnaryUnion_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSUnionCascaded_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSUnionCascaded_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSPointOnSurface_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSPointOnSurface_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGetCentroid_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGetCentroid_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSNode_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSNode_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSPolygonize(geoms::Ptr{Ptr{GEOSGeometry}},ngeoms::Integer)
    ccall((:GEOSPolygonize,libgeos),Ptr{GEOSGeometry},(Ptr{Ptr{GEOSGeometry}},UInt32),geoms,ngeoms)
end

function GEOSPolygonizer_getCutEdges(geoms::Ptr{Ptr{GEOSGeometry}},ngeoms::Integer)
    ccall((:GEOSPolygonizer_getCutEdges,libgeos),Ptr{GEOSGeometry},(Ptr{Ptr{GEOSGeometry}},UInt32),geoms,ngeoms)
end

function GEOSPolygonize_full(input::Ptr{GEOSGeometry},cuts::Ptr{Ptr{GEOSGeometry}},dangles::Ptr{Ptr{GEOSGeometry}},invalid::Ptr{Ptr{GEOSGeometry}})
    ccall((:GEOSPolygonize_full,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Ptr{Ptr{GEOSGeometry}},Ptr{Ptr{GEOSGeometry}},Ptr{Ptr{GEOSGeometry}}),input,cuts,dangles,invalid)
end

function GEOSLineMerge(g::Ptr{GEOSGeometry})
    ccall((:GEOSLineMerge,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSSimplify(g::Ptr{GEOSGeometry},tolerance::Real)
    ccall((:GEOSSimplify,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cdouble),g,tolerance)
end

function GEOSTopologyPreserveSimplify(g::Ptr{GEOSGeometry},tolerance::Real)
    ccall((:GEOSTopologyPreserveSimplify,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cdouble),g,tolerance)
end

function GEOSPolygonize_r(handle::GEOSContextHandle_t,geoms::Ptr{Ptr{GEOSGeometry}},ngeoms::Integer)
    ccall((:GEOSPolygonize_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{Ptr{GEOSGeometry}},UInt32),handle,geoms,ngeoms)
end

function GEOSPolygonizer_getCutEdges_r(handle::GEOSContextHandle_t,geoms::Ptr{Ptr{GEOSGeometry}},ngeoms::Integer)
    ccall((:GEOSPolygonizer_getCutEdges_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{Ptr{GEOSGeometry}},UInt32),handle,geoms,ngeoms)
end

function GEOSPolygonize_full_r(handle::GEOSContextHandle_t,input::Ptr{GEOSGeometry},cuts::Ptr{Ptr{GEOSGeometry}},dangles::Ptr{Ptr{GEOSGeometry}},invalidRings::Ptr{Ptr{GEOSGeometry}})
    ccall((:GEOSPolygonize_full_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{Ptr{GEOSGeometry}},Ptr{Ptr{GEOSGeometry}},Ptr{Ptr{GEOSGeometry}}),handle,input,cuts,dangles,invalidRings)
end

function GEOSLineMerge_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSLineMerge_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSSimplify_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},tolerance::Real)
    ccall((:GEOSSimplify_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cdouble),handle,g,tolerance)
end

function GEOSTopologyPreserveSimplify_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},tolerance::Real)
    ccall((:GEOSTopologyPreserveSimplify_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cdouble),handle,g,tolerance)
end

function GEOSGeom_extractUniquePoints(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_extractUniquePoints,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSGeom_extractUniquePoints_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_extractUniquePoints_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSSharedPaths(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSSharedPaths,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSSharedPaths_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSSharedPaths_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSSnap(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},tolerance::Real)
    ccall((:GEOSSnap,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Ptr{GEOSGeometry},Cdouble),g1,g2,tolerance)
end

function GEOSSnap_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},tolerance::Real)
    ccall((:GEOSSnap_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry},Cdouble),handle,g1,g2,tolerance)
end

function GEOSDelaunayTriangulation(g::Ptr{GEOSGeometry},tolerance::Real,onlyEdges::Integer)
    ccall((:GEOSDelaunayTriangulation,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cdouble,Cint),g,tolerance,onlyEdges)
end

function GEOSDelaunayTriangulation_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},tolerance::Real,onlyEdges::Integer)
    ccall((:GEOSDelaunayTriangulation_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cdouble,Cint),handle,g,tolerance,onlyEdges)
end

function GEOSDisjoint(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSDisjoint,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSTouches(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSTouches,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSIntersects(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSIntersects,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSCrosses(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSCrosses,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSWithin(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSWithin,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSContains(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSContains,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSOverlaps(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSOverlaps,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSEquals(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSEquals,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSEqualsExact(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},tolerance::Real)
    ccall((:GEOSEqualsExact,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry},Cdouble),g1,g2,tolerance)
end

function GEOSCovers(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSCovers,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSCoveredBy(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSCoveredBy,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSDisjoint_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSDisjoint_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSTouches_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSTouches_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSIntersects_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSIntersects_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSCrosses_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSCrosses_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSWithin_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSWithin_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSContains_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSContains_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSOverlaps_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSOverlaps_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSEquals_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSEquals_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSEqualsExact_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},tolerance::Real)
    ccall((:GEOSEqualsExact_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry},Cdouble),handle,g1,g2,tolerance)
end

function GEOSCovers_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSCovers_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSCoveredBy_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSCoveredBy_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSPrepare(g::Ptr{GEOSGeometry})
    ccall((:GEOSPrepare,libgeos),Ptr{GEOSPreparedGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSPreparedGeom_destroy(g::Ptr{GEOSPreparedGeometry})
    ccall((:GEOSPreparedGeom_destroy,libgeos),Void,(Ptr{GEOSPreparedGeometry},),g)
end

function GEOSPreparedContains(pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedContains,libgeos),UInt8,(Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),pg1,g2)
end

function GEOSPreparedContainsProperly(pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedContainsProperly,libgeos),UInt8,(Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),pg1,g2)
end

function GEOSPreparedCoveredBy(pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedCoveredBy,libgeos),UInt8,(Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),pg1,g2)
end

function GEOSPreparedCovers(pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedCovers,libgeos),UInt8,(Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),pg1,g2)
end

function GEOSPreparedCrosses(pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedCrosses,libgeos),UInt8,(Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),pg1,g2)
end

function GEOSPreparedDisjoint(pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedDisjoint,libgeos),UInt8,(Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),pg1,g2)
end

function GEOSPreparedIntersects(pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedIntersects,libgeos),UInt8,(Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),pg1,g2)
end

function GEOSPreparedOverlaps(pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedOverlaps,libgeos),UInt8,(Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),pg1,g2)
end

function GEOSPreparedTouches(pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedTouches,libgeos),UInt8,(Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),pg1,g2)
end

function GEOSPreparedWithin(pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedWithin,libgeos),UInt8,(Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),pg1,g2)
end

function GEOSPrepare_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSPrepare_r,libgeos),Ptr{GEOSPreparedGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSPreparedGeom_destroy_r(handle::GEOSContextHandle_t,g::Ptr{GEOSPreparedGeometry})
    ccall((:GEOSPreparedGeom_destroy_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSPreparedGeometry}),handle,g)
end

function GEOSPreparedContains_r(handle::GEOSContextHandle_t,pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedContains_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),handle,pg1,g2)
end

function GEOSPreparedContainsProperly_r(handle::GEOSContextHandle_t,pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedContainsProperly_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),handle,pg1,g2)
end

function GEOSPreparedCoveredBy_r(handle::GEOSContextHandle_t,pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedCoveredBy_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),handle,pg1,g2)
end

function GEOSPreparedCovers_r(handle::GEOSContextHandle_t,pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedCovers_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),handle,pg1,g2)
end

function GEOSPreparedCrosses_r(handle::GEOSContextHandle_t,pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedCrosses_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),handle,pg1,g2)
end

function GEOSPreparedDisjoint_r(handle::GEOSContextHandle_t,pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedDisjoint_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),handle,pg1,g2)
end

function GEOSPreparedIntersects_r(handle::GEOSContextHandle_t,pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedIntersects_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),handle,pg1,g2)
end

function GEOSPreparedOverlaps_r(handle::GEOSContextHandle_t,pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedOverlaps_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),handle,pg1,g2)
end

function GEOSPreparedTouches_r(handle::GEOSContextHandle_t,pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedTouches_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),handle,pg1,g2)
end

function GEOSPreparedWithin_r(handle::GEOSContextHandle_t,pg1::Ptr{GEOSPreparedGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSPreparedWithin_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSPreparedGeometry},Ptr{GEOSGeometry}),handle,pg1,g2)
end

function GEOSSTRtree_create(nodeCapacity::Integer)
    ccall((:GEOSSTRtree_create,libgeos),Ptr{GEOSSTRtree},(Csize_t,),nodeCapacity)
end

function GEOSSTRtree_insert(tree::Ptr{GEOSSTRtree},g::Ptr{GEOSGeometry},item::Ptr{Void})
    ccall((:GEOSSTRtree_insert,libgeos),Void,(Ptr{GEOSSTRtree},Ptr{GEOSGeometry},Ptr{Void}),tree,g,item)
end

function GEOSSTRtree_query(tree::Ptr{GEOSSTRtree},g::Ptr{GEOSGeometry},callback::Integer,userdata::Ptr{Void})
    ccall((:GEOSSTRtree_query,libgeos),Void,(Ptr{GEOSSTRtree},Ptr{GEOSGeometry},Cint,Ptr{Void}),tree,g,callback,userdata)
end

function GEOSSTRtree_iterate(tree::Ptr{GEOSSTRtree},callback::Integer,userdata::Ptr{Void})
    ccall((:GEOSSTRtree_iterate,libgeos),Void,(Ptr{GEOSSTRtree},Cint,Ptr{Void}),tree,callback,userdata)
end

function GEOSSTRtree_remove(tree::Ptr{GEOSSTRtree},g::Ptr{GEOSGeometry},item::Ptr{Void})
    ccall((:GEOSSTRtree_remove,libgeos),UInt8,(Ptr{GEOSSTRtree},Ptr{GEOSGeometry},Ptr{Void}),tree,g,item)
end

function GEOSSTRtree_destroy(tree::Ptr{GEOSSTRtree})
    ccall((:GEOSSTRtree_destroy,libgeos),Void,(Ptr{GEOSSTRtree},),tree)
end

function GEOSSTRtree_create_r(handle::GEOSContextHandle_t,nodeCapacity::Integer)
    ccall((:GEOSSTRtree_create_r,libgeos),Ptr{GEOSSTRtree},(GEOSContextHandle_t,Csize_t),handle,nodeCapacity)
end

function GEOSSTRtree_insert_r(handle::GEOSContextHandle_t,tree::Ptr{GEOSSTRtree},g::Ptr{GEOSGeometry},item::Ptr{Void})
    ccall((:GEOSSTRtree_insert_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSSTRtree},Ptr{GEOSGeometry},Ptr{Void}),handle,tree,g,item)
end

function GEOSSTRtree_query_r(handle::GEOSContextHandle_t,tree::Ptr{GEOSSTRtree},g::Ptr{GEOSGeometry},callback::Integer,userdata::Ptr{Void})
    ccall((:GEOSSTRtree_query_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSSTRtree},Ptr{GEOSGeometry},Cint,Ptr{Void}),handle,tree,g,callback,userdata)
end

function GEOSSTRtree_iterate_r(handle::GEOSContextHandle_t,tree::Ptr{GEOSSTRtree},callback::Integer,userdata::Ptr{Void})
    ccall((:GEOSSTRtree_iterate_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSSTRtree},Cint,Ptr{Void}),handle,tree,callback,userdata)
end

function GEOSSTRtree_remove_r(handle::GEOSContextHandle_t,tree::Ptr{GEOSSTRtree},g::Ptr{GEOSGeometry},item::Ptr{Void})
    ccall((:GEOSSTRtree_remove_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSSTRtree},Ptr{GEOSGeometry},Ptr{Void}),handle,tree,g,item)
end

function GEOSSTRtree_destroy_r(handle::GEOSContextHandle_t,tree::Ptr{GEOSSTRtree})
    ccall((:GEOSSTRtree_destroy_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSSTRtree}),handle,tree)
end

function GEOSisEmpty(g::Ptr{GEOSGeometry})
    ccall((:GEOSisEmpty,libgeos),UInt8,(Ptr{GEOSGeometry},),g)
end

function GEOSisSimple(g::Ptr{GEOSGeometry})
    ccall((:GEOSisSimple,libgeos),UInt8,(Ptr{GEOSGeometry},),g)
end

function GEOSisRing(g::Ptr{GEOSGeometry})
    ccall((:GEOSisRing,libgeos),UInt8,(Ptr{GEOSGeometry},),g)
end

function GEOSHasZ(g::Ptr{GEOSGeometry})
    ccall((:GEOSHasZ,libgeos),UInt8,(Ptr{GEOSGeometry},),g)
end

function GEOSisClosed(g::Ptr{GEOSGeometry})
    ccall((:GEOSisClosed,libgeos),UInt8,(Ptr{GEOSGeometry},),g)
end

function GEOSisEmpty_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSisEmpty_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSisSimple_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSisSimple_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSisRing_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSisRing_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSHasZ_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSHasZ_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSisClosed_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSisClosed_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSRelatePattern(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},pat::Ptr{UInt8})
    ccall((:GEOSRelatePattern,libgeos),UInt8,(Ptr{GEOSGeometry},Ptr{GEOSGeometry},Ptr{UInt8}),g1,g2,pat)
end

function GEOSRelatePattern_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},pat::Ptr{UInt8})
    ccall((:GEOSRelatePattern_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry},Ptr{UInt8}),handle,g1,g2,pat)
end

function GEOSRelate(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSRelate,libgeos),Ptr{UInt8},(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSRelate_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSRelate_r,libgeos),Ptr{UInt8},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSRelatePatternMatch(mat::Ptr{UInt8},pat::Ptr{UInt8})
    ccall((:GEOSRelatePatternMatch,libgeos),UInt8,(Ptr{UInt8},Ptr{UInt8}),mat,pat)
end

function GEOSRelatePatternMatch_r(handle::GEOSContextHandle_t,mat::Ptr{UInt8},pat::Ptr{UInt8})
    ccall((:GEOSRelatePatternMatch_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{UInt8},Ptr{UInt8}),handle,mat,pat)
end

function GEOSRelateBoundaryNodeRule(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},bnr::Integer)
    ccall((:GEOSRelateBoundaryNodeRule,libgeos),Ptr{UInt8},(Ptr{GEOSGeometry},Ptr{GEOSGeometry},Cint),g1,g2,bnr)
end

function GEOSRelateBoundaryNodeRule_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},bnr::Integer)
    ccall((:GEOSRelateBoundaryNodeRule_r,libgeos),Ptr{UInt8},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry},Cint),handle,g1,g2,bnr)
end

function GEOSisValid(g::Ptr{GEOSGeometry})
    ccall((:GEOSisValid,libgeos),UInt8,(Ptr{GEOSGeometry},),g)
end

function GEOSisValid_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSisValid_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSisValidReason(g::Ptr{GEOSGeometry})
    ccall((:GEOSisValidReason,libgeos),Ptr{UInt8},(Ptr{GEOSGeometry},),g)
end

function GEOSisValidReason_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSisValidReason_r,libgeos),Ptr{UInt8},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSisValidDetail(g::Ptr{GEOSGeometry},flags::Integer,reason::Ptr{Ptr{UInt8}},location::Ptr{Ptr{GEOSGeometry}})
    ccall((:GEOSisValidDetail,libgeos),UInt8,(Ptr{GEOSGeometry},Cint,Ptr{Ptr{UInt8}},Ptr{Ptr{GEOSGeometry}}),g,flags,reason,location)
end

function GEOSisValidDetail_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},flags::Integer,reason::Ptr{Ptr{UInt8}},location::Ptr{Ptr{GEOSGeometry}})
    ccall((:GEOSisValidDetail_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSGeometry},Cint,Ptr{Ptr{UInt8}},Ptr{Ptr{GEOSGeometry}}),handle,g,flags,reason,location)
end

function GEOSGeomType(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomType,libgeos),Ptr{UInt8},(Ptr{GEOSGeometry},),g)
end

function GEOSGeomType_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomType_r,libgeos),Ptr{UInt8},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGeomTypeId(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomTypeId,libgeos),Cint,(Ptr{GEOSGeometry},),g)
end

function GEOSGeomTypeId_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomTypeId_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGetSRID(g::Ptr{GEOSGeometry})
    ccall((:GEOSGetSRID,libgeos),Cint,(Ptr{GEOSGeometry},),g)
end

function GEOSGetSRID_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGetSRID_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSSetSRID(g::Ptr{GEOSGeometry},SRID::Integer)
    ccall((:GEOSSetSRID,libgeos),Void,(Ptr{GEOSGeometry},Cint),g,SRID)
end

function GEOSSetSRID_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},SRID::Integer)
    ccall((:GEOSSetSRID_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSGeometry},Cint),handle,g,SRID)
end

function GEOSGetNumGeometries(g::Ptr{GEOSGeometry})
    ccall((:GEOSGetNumGeometries,libgeos),Cint,(Ptr{GEOSGeometry},),g)
end

function GEOSGetNumGeometries_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGetNumGeometries_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGetGeometryN(g::Ptr{GEOSGeometry},n::Integer)
    ccall((:GEOSGetGeometryN,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cint),g,n)
end

function GEOSGetGeometryN_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},n::Integer)
    ccall((:GEOSGetGeometryN_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cint),handle,g,n)
end

function GEOSNormalize(g::Ptr{GEOSGeometry})
    ccall((:GEOSNormalize,libgeos),Cint,(Ptr{GEOSGeometry},),g)
end

function GEOSNormalize_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSNormalize_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGetNumInteriorRings(g::Ptr{GEOSGeometry})
    ccall((:GEOSGetNumInteriorRings,libgeos),Cint,(Ptr{GEOSGeometry},),g)
end

function GEOSGetNumInteriorRings_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGetNumInteriorRings_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGeomGetNumPoints(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomGetNumPoints,libgeos),Cint,(Ptr{GEOSGeometry},),g)
end

function GEOSGeomGetNumPoints_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomGetNumPoints_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGeomGetX(g::Ptr{GEOSGeometry},x::Ptr{Cdouble})
    ccall((:GEOSGeomGetX,libgeos),Cint,(Ptr{GEOSGeometry},Ptr{Cdouble}),g,x)
end

function GEOSGeomGetY(g::Ptr{GEOSGeometry},y::Ptr{Cdouble})
    ccall((:GEOSGeomGetY,libgeos),Cint,(Ptr{GEOSGeometry},Ptr{Cdouble}),g,y)
end

function GEOSGeomGetX_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},x::Ptr{Cdouble})
    ccall((:GEOSGeomGetX_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{Cdouble}),handle,g,x)
end

function GEOSGeomGetY_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},y::Ptr{Cdouble})
    ccall((:GEOSGeomGetY_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{Cdouble}),handle,g,y)
end

function GEOSGetInteriorRingN(g::Ptr{GEOSGeometry},n::Integer)
    ccall((:GEOSGetInteriorRingN,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cint),g,n)
end

function GEOSGetInteriorRingN_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},n::Integer)
    ccall((:GEOSGetInteriorRingN_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cint),handle,g,n)
end

function GEOSGetExteriorRing(g::Ptr{GEOSGeometry})
    ccall((:GEOSGetExteriorRing,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSGetExteriorRing_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGetExteriorRing_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGetNumCoordinates(g::Ptr{GEOSGeometry})
    ccall((:GEOSGetNumCoordinates,libgeos),Cint,(Ptr{GEOSGeometry},),g)
end

function GEOSGetNumCoordinates_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGetNumCoordinates_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGeom_getCoordSeq(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_getCoordSeq,libgeos),Ptr{GEOSCoordSequence},(Ptr{GEOSGeometry},),g)
end

function GEOSGeom_getCoordSeq_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_getCoordSeq_r,libgeos),Ptr{GEOSCoordSequence},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGeom_getDimensions(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_getDimensions,libgeos),Cint,(Ptr{GEOSGeometry},),g)
end

function GEOSGeom_getDimensions_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_getDimensions_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGeom_getCoordinateDimension(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_getCoordinateDimension,libgeos),Cint,(Ptr{GEOSGeometry},),g)
end

function GEOSGeom_getCoordinateDimension_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeom_getCoordinateDimension_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGeomGetPointN(g::Ptr{GEOSGeometry},n::Integer)
    ccall((:GEOSGeomGetPointN,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},Cint),g,n)
end

function GEOSGeomGetStartPoint(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomGetStartPoint,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSGeomGetEndPoint(g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomGetEndPoint,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSGeometry},),g)
end

function GEOSGeomGetPointN_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},n::Integer)
    ccall((:GEOSGeomGetPointN_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry},Cint),handle,g,n)
end

function GEOSGeomGetStartPoint_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomGetStartPoint_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSGeomGetEndPoint_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry})
    ccall((:GEOSGeomGetEndPoint_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSGeometry}),handle,g)
end

function GEOSArea(g::Ptr{GEOSGeometry},area::Ptr{Cdouble})
    ccall((:GEOSArea,libgeos),Cint,(Ptr{GEOSGeometry},Ptr{Cdouble}),g,area)
end

function GEOSLength(g::Ptr{GEOSGeometry},length::Ptr{Cdouble})
    ccall((:GEOSLength,libgeos),Cint,(Ptr{GEOSGeometry},Ptr{Cdouble}),g,length)
end

function GEOSDistance(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},dist::Ptr{Cdouble})
    ccall((:GEOSDistance,libgeos),Cint,(Ptr{GEOSGeometry},Ptr{GEOSGeometry},Ptr{Cdouble}),g1,g2,dist)
end

function GEOSHausdorffDistance(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},dist::Ptr{Cdouble})
    ccall((:GEOSHausdorffDistance,libgeos),Cint,(Ptr{GEOSGeometry},Ptr{GEOSGeometry},Ptr{Cdouble}),g1,g2,dist)
end

function GEOSHausdorffDistanceDensify(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},densifyFrac::Real,dist::Ptr{Cdouble})
    ccall((:GEOSHausdorffDistanceDensify,libgeos),Cint,(Ptr{GEOSGeometry},Ptr{GEOSGeometry},Cdouble,Ptr{Cdouble}),g1,g2,densifyFrac,dist)
end

function GEOSGeomGetLength(g::Ptr{GEOSGeometry},length::Ptr{Cdouble})
    ccall((:GEOSGeomGetLength,libgeos),Cint,(Ptr{GEOSGeometry},Ptr{Cdouble}),g,length)
end

function GEOSArea_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},area::Ptr{Cdouble})
    ccall((:GEOSArea_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{Cdouble}),handle,g,area)
end

function GEOSLength_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},length::Ptr{Cdouble})
    ccall((:GEOSLength_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{Cdouble}),handle,g,length)
end

function GEOSDistance_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},dist::Ptr{Cdouble})
    ccall((:GEOSDistance_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry},Ptr{Cdouble}),handle,g1,g2,dist)
end

function GEOSHausdorffDistance_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},dist::Ptr{Cdouble})
    ccall((:GEOSHausdorffDistance_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry},Ptr{Cdouble}),handle,g1,g2,dist)
end

function GEOSHausdorffDistanceDensify_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry},densifyFrac::Real,dist::Ptr{Cdouble})
    ccall((:GEOSHausdorffDistanceDensify_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry},Cdouble,Ptr{Cdouble}),handle,g1,g2,densifyFrac,dist)
end

function GEOSGeomGetLength_r(handle::GEOSContextHandle_t,g::Ptr{GEOSGeometry},length::Ptr{Cdouble})
    ccall((:GEOSGeomGetLength_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{Cdouble}),handle,g,length)
end

function GEOSNearestPoints(g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSNearestPoints,libgeos),Ptr{GEOSCoordSequence},(Ptr{GEOSGeometry},Ptr{GEOSGeometry}),g1,g2)
end

function GEOSNearestPoints_r(handle::GEOSContextHandle_t,g1::Ptr{GEOSGeometry},g2::Ptr{GEOSGeometry})
    ccall((:GEOSNearestPoints_r,libgeos),Ptr{GEOSCoordSequence},(GEOSContextHandle_t,Ptr{GEOSGeometry},Ptr{GEOSGeometry}),handle,g1,g2)
end

function GEOSOrientationIndex(Ax::Real,Ay::Real,Bx::Real,By::Real,Px::Real,Py::Real)
    ccall((:GEOSOrientationIndex,libgeos),Cint,(Cdouble,Cdouble,Cdouble,Cdouble,Cdouble,Cdouble),Ax,Ay,Bx,By,Px,Py)
end

function GEOSOrientationIndex_r(handle::GEOSContextHandle_t,Ax::Real,Ay::Real,Bx::Real,By::Real,Px::Real,Py::Real)
    ccall((:GEOSOrientationIndex_r,libgeos),Cint,(GEOSContextHandle_t,Cdouble,Cdouble,Cdouble,Cdouble,Cdouble,Cdouble),handle,Ax,Ay,Bx,By,Px,Py)
end

function GEOSWKTReader_destroy(reader::Ptr{GEOSWKTReader})
    ccall((:GEOSWKTReader_destroy,libgeos),Void,(Ptr{GEOSWKTReader},),reader)
end

function GEOSWKTReader_read(reader::Ptr{GEOSWKTReader},wkt::Ptr{UInt8})
    ccall((:GEOSWKTReader_read,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSWKTReader},Ptr{UInt8}),reader,wkt)
end

function GEOSWKTReader_create_r(handle::GEOSContextHandle_t)
    ccall((:GEOSWKTReader_create_r,libgeos),Ptr{GEOSWKTReader},(GEOSContextHandle_t,),handle)
end

function GEOSWKTReader_destroy_r(handle::GEOSContextHandle_t,reader::Ptr{GEOSWKTReader})
    ccall((:GEOSWKTReader_destroy_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSWKTReader}),handle,reader)
end

function GEOSWKTReader_read_r(handle::GEOSContextHandle_t,reader::Ptr{GEOSWKTReader},wkt::Ptr{UInt8})
    ccall((:GEOSWKTReader_read_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSWKTReader},Ptr{UInt8}),handle,reader,wkt)
end

function GEOSWKTWriter_destroy(writer::Ptr{GEOSWKTWriter})
    ccall((:GEOSWKTWriter_destroy,libgeos),Void,(Ptr{GEOSWKTWriter},),writer)
end

function GEOSWKTWriter_write(writer::Ptr{GEOSWKTWriter},g::Ptr{GEOSGeometry})
    ccall((:GEOSWKTWriter_write,libgeos),Ptr{UInt8},(Ptr{GEOSWKTWriter},Ptr{GEOSGeometry}),writer,g)
end

function GEOSWKTWriter_setTrim(writer::Ptr{GEOSWKTWriter},trim::UInt8)
    ccall((:GEOSWKTWriter_setTrim,libgeos),Void,(Ptr{GEOSWKTWriter},UInt8),writer,trim)
end

function GEOSWKTWriter_setRoundingPrecision(writer::Ptr{GEOSWKTWriter},precision::Integer)
    ccall((:GEOSWKTWriter_setRoundingPrecision,libgeos),Void,(Ptr{GEOSWKTWriter},Cint),writer,precision)
end

function GEOSWKTWriter_setOutputDimension(writer::Ptr{GEOSWKTWriter},dim::Integer)
    ccall((:GEOSWKTWriter_setOutputDimension,libgeos),Void,(Ptr{GEOSWKTWriter},Cint),writer,dim)
end

function GEOSWKTWriter_getOutputDimension(writer::Ptr{GEOSWKTWriter})
    ccall((:GEOSWKTWriter_getOutputDimension,libgeos),Cint,(Ptr{GEOSWKTWriter},),writer)
end

function GEOSWKTWriter_setOld3D(writer::Ptr{GEOSWKTWriter},useOld3D::Integer)
    ccall((:GEOSWKTWriter_setOld3D,libgeos),Void,(Ptr{GEOSWKTWriter},Cint),writer,useOld3D)
end

function GEOSWKTWriter_create_r(handle::GEOSContextHandle_t)
    ccall((:GEOSWKTWriter_create_r,libgeos),Ptr{GEOSWKTWriter},(GEOSContextHandle_t,),handle)
end

function GEOSWKTWriter_destroy_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKTWriter})
    ccall((:GEOSWKTWriter_destroy_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSWKTWriter}),handle,writer)
end

function GEOSWKTWriter_write_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKTWriter},g::Ptr{GEOSGeometry})
    ccall((:GEOSWKTWriter_write_r,libgeos),Ptr{UInt8},(GEOSContextHandle_t,Ptr{GEOSWKTWriter},Ptr{GEOSGeometry}),handle,writer,g)
end

function GEOSWKTWriter_setTrim_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKTWriter},trim::UInt8)
    ccall((:GEOSWKTWriter_setTrim_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSWKTWriter},UInt8),handle,writer,trim)
end

function GEOSWKTWriter_setRoundingPrecision_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKTWriter},precision::Integer)
    ccall((:GEOSWKTWriter_setRoundingPrecision_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSWKTWriter},Cint),handle,writer,precision)
end

function GEOSWKTWriter_setOutputDimension_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKTWriter},dim::Integer)
    ccall((:GEOSWKTWriter_setOutputDimension_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSWKTWriter},Cint),handle,writer,dim)
end

function GEOSWKTWriter_getOutputDimension_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKTWriter})
    ccall((:GEOSWKTWriter_getOutputDimension_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSWKTWriter}),handle,writer)
end

function GEOSWKTWriter_setOld3D_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKTWriter},useOld3D::Integer)
    ccall((:GEOSWKTWriter_setOld3D_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSWKTWriter},Cint),handle,writer,useOld3D)
end

function GEOSWKBReader_destroy(reader::Ptr{GEOSWKBReader})
    ccall((:GEOSWKBReader_destroy,libgeos),Void,(Ptr{GEOSWKBReader},),reader)
end

function GEOSWKBReader_read(reader::Ptr{GEOSWKBReader},wkb::Ptr{Cuchar},size::Integer)
    ccall((:GEOSWKBReader_read,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSWKBReader},Ptr{Cuchar},Csize_t),reader,wkb,size)
end

function GEOSWKBReader_readHEX(reader::Ptr{GEOSWKBReader},hex::Ptr{Cuchar},size::Integer)
    ccall((:GEOSWKBReader_readHEX,libgeos),Ptr{GEOSGeometry},(Ptr{GEOSWKBReader},Ptr{Cuchar},Csize_t),reader,hex,size)
end

function GEOSWKBReader_create_r(handle::GEOSContextHandle_t)
    ccall((:GEOSWKBReader_create_r,libgeos),Ptr{GEOSWKBReader},(GEOSContextHandle_t,),handle)
end

function GEOSWKBReader_destroy_r(handle::GEOSContextHandle_t,reader::Ptr{GEOSWKBReader})
    ccall((:GEOSWKBReader_destroy_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSWKBReader}),handle,reader)
end

function GEOSWKBReader_read_r(handle::GEOSContextHandle_t,reader::Ptr{GEOSWKBReader},wkb::Ptr{Cuchar},size::Integer)
    ccall((:GEOSWKBReader_read_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSWKBReader},Ptr{Cuchar},Csize_t),handle,reader,wkb,size)
end

function GEOSWKBReader_readHEX_r(handle::GEOSContextHandle_t,reader::Ptr{GEOSWKBReader},hex::Ptr{Cuchar},size::Integer)
    ccall((:GEOSWKBReader_readHEX_r,libgeos),Ptr{GEOSGeometry},(GEOSContextHandle_t,Ptr{GEOSWKBReader},Ptr{Cuchar},Csize_t),handle,reader,hex,size)
end

function GEOSWKBWriter_destroy(writer::Ptr{GEOSWKBWriter})
    ccall((:GEOSWKBWriter_destroy,libgeos),Void,(Ptr{GEOSWKBWriter},),writer)
end

function GEOSWKBWriter_create_r(handle::GEOSContextHandle_t)
    ccall((:GEOSWKBWriter_create_r,libgeos),Ptr{GEOSWKBWriter},(GEOSContextHandle_t,),handle)
end

function GEOSWKBWriter_destroy_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKBWriter})
    ccall((:GEOSWKBWriter_destroy_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSWKBWriter}),handle,writer)
end

function GEOSWKBWriter_write(writer::Ptr{GEOSWKBWriter},g::Ptr{GEOSGeometry},size::Ptr{Csize_t})
    ccall((:GEOSWKBWriter_write,libgeos),Ptr{Cuchar},(Ptr{GEOSWKBWriter},Ptr{GEOSGeometry},Ptr{Csize_t}),writer,g,size)
end

function GEOSWKBWriter_writeHEX(writer::Ptr{GEOSWKBWriter},g::Ptr{GEOSGeometry},size::Ptr{Csize_t})
    ccall((:GEOSWKBWriter_writeHEX,libgeos),Ptr{Cuchar},(Ptr{GEOSWKBWriter},Ptr{GEOSGeometry},Ptr{Csize_t}),writer,g,size)
end

function GEOSWKBWriter_write_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKBWriter},g::Ptr{GEOSGeometry},size::Ptr{Csize_t})
    ccall((:GEOSWKBWriter_write_r,libgeos),Ptr{Cuchar},(GEOSContextHandle_t,Ptr{GEOSWKBWriter},Ptr{GEOSGeometry},Ptr{Csize_t}),handle,writer,g,size)
end

function GEOSWKBWriter_writeHEX_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKBWriter},g::Ptr{GEOSGeometry},size::Ptr{Csize_t})
    ccall((:GEOSWKBWriter_writeHEX_r,libgeos),Ptr{Cuchar},(GEOSContextHandle_t,Ptr{GEOSWKBWriter},Ptr{GEOSGeometry},Ptr{Csize_t}),handle,writer,g,size)
end

function GEOSWKBWriter_getOutputDimension(writer::Ptr{GEOSWKBWriter})
    ccall((:GEOSWKBWriter_getOutputDimension,libgeos),Cint,(Ptr{GEOSWKBWriter},),writer)
end

function GEOSWKBWriter_setOutputDimension(writer::Ptr{GEOSWKBWriter},newDimension::Integer)
    ccall((:GEOSWKBWriter_setOutputDimension,libgeos),Void,(Ptr{GEOSWKBWriter},Cint),writer,newDimension)
end

function GEOSWKBWriter_getOutputDimension_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKBWriter})
    ccall((:GEOSWKBWriter_getOutputDimension_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSWKBWriter}),handle,writer)
end

function GEOSWKBWriter_setOutputDimension_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKBWriter},newDimension::Integer)
    ccall((:GEOSWKBWriter_setOutputDimension_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSWKBWriter},Cint),handle,writer,newDimension)
end

function GEOSWKBWriter_getByteOrder(writer::Ptr{GEOSWKBWriter})
    ccall((:GEOSWKBWriter_getByteOrder,libgeos),Cint,(Ptr{GEOSWKBWriter},),writer)
end

function GEOSWKBWriter_setByteOrder(writer::Ptr{GEOSWKBWriter},byteOrder::Integer)
    ccall((:GEOSWKBWriter_setByteOrder,libgeos),Void,(Ptr{GEOSWKBWriter},Cint),writer,byteOrder)
end

function GEOSWKBWriter_getByteOrder_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKBWriter})
    ccall((:GEOSWKBWriter_getByteOrder_r,libgeos),Cint,(GEOSContextHandle_t,Ptr{GEOSWKBWriter}),handle,writer)
end

function GEOSWKBWriter_setByteOrder_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKBWriter},byteOrder::Integer)
    ccall((:GEOSWKBWriter_setByteOrder_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSWKBWriter},Cint),handle,writer,byteOrder)
end

function GEOSWKBWriter_getIncludeSRID(writer::Ptr{GEOSWKBWriter})
    ccall((:GEOSWKBWriter_getIncludeSRID,libgeos),UInt8,(Ptr{GEOSWKBWriter},),writer)
end

function GEOSWKBWriter_setIncludeSRID(writer::Ptr{GEOSWKBWriter},writeSRID::UInt8)
    ccall((:GEOSWKBWriter_setIncludeSRID,libgeos),Void,(Ptr{GEOSWKBWriter},UInt8),writer,writeSRID)
end

function GEOSWKBWriter_getIncludeSRID_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKBWriter})
    ccall((:GEOSWKBWriter_getIncludeSRID_r,libgeos),UInt8,(GEOSContextHandle_t,Ptr{GEOSWKBWriter}),handle,writer)
end

function GEOSWKBWriter_setIncludeSRID_r(handle::GEOSContextHandle_t,writer::Ptr{GEOSWKBWriter},writeSRID::UInt8)
    ccall((:GEOSWKBWriter_setIncludeSRID_r,libgeos),Void,(GEOSContextHandle_t,Ptr{GEOSWKBWriter},UInt8),handle,writer,writeSRID)
end

function GEOSFree(buffer::Ptr{Void})
    ccall((:GEOSFree,libgeos),Void,(Ptr{Void},),buffer)
end

function GEOSFree_r(handle::GEOSContextHandle_t,buffer::Ptr{Void})
    ccall((:GEOSFree_r,libgeos),Void,(GEOSContextHandle_t,Ptr{Void}),handle,buffer)
end


text:
# Autogenerated wrapper script for TempestRemap_jll for x86_64-apple-darwin
export AnalyzeMap_exe, ApplyOfflineMap_exe, CalculateDiffNorms_exe, CoarsenRectilinearData_exe, GenerateCSMesh_exe, GenerateGLLMetaData_exe, GenerateICOMesh_exe, GenerateLambertConfConicMesh_exe, GenerateOfflineMap_exe, GenerateOverlapMesh_exe, GenerateOverlapMesh_v1_exe, GenerateRLLMesh_exe, GenerateRectilinearMeshFromFile_exe, GenerateStereographicMesh_exe, GenerateTestData_exe, GenerateTransectMesh_exe, GenerateTransposeMap_exe, GenerateUTMMesh_exe, GenerateVolumetricMesh_exe, MeshToTxt_exe, RestructureData_exe, ShpToMesh_exe, VerticalInterpolate_exe, libTempestRemap

using OpenBLAS32_jll
using NetCDF_jll
JLLWrappers.@generate_wrapper_header("TempestRemap")
JLLWrappers.@declare_library_product(libTempestRemap, "@rpath/libTempestRemap.0.dylib")
JLLWrappers.@declare_executable_product(AnalyzeMap_exe)
JLLWrappers.@declare_executable_product(ApplyOfflineMap_exe)
JLLWrappers.@declare_executable_product(CalculateDiffNorms_exe)
JLLWrappers.@declare_executable_product(CoarsenRectilinearData_exe)
JLLWrappers.@declare_executable_product(GenerateCSMesh_exe)
JLLWrappers.@declare_executable_product(GenerateGLLMetaData_exe)
JLLWrappers.@declare_executable_product(GenerateICOMesh_exe)
JLLWrappers.@declare_executable_product(GenerateLambertConfConicMesh_exe)
JLLWrappers.@declare_executable_product(GenerateOfflineMap_exe)
JLLWrappers.@declare_executable_product(GenerateOverlapMesh_exe)
JLLWrappers.@declare_executable_product(GenerateOverlapMesh_v1_exe)
JLLWrappers.@declare_executable_product(GenerateRLLMesh_exe)
JLLWrappers.@declare_executable_product(GenerateRectilinearMeshFromFile_exe)
JLLWrappers.@declare_executable_product(GenerateStereographicMesh_exe)
JLLWrappers.@declare_executable_product(GenerateTestData_exe)
JLLWrappers.@declare_executable_product(GenerateTransectMesh_exe)
JLLWrappers.@declare_executable_product(GenerateTransposeMap_exe)
JLLWrappers.@declare_executable_product(GenerateUTMMesh_exe)
JLLWrappers.@declare_executable_product(GenerateVolumetricMesh_exe)
JLLWrappers.@declare_executable_product(MeshToTxt_exe)
JLLWrappers.@declare_executable_product(RestructureData_exe)
JLLWrappers.@declare_executable_product(ShpToMesh_exe)
JLLWrappers.@declare_executable_product(VerticalInterpolate_exe)
function __init__()
    JLLWrappers.@generate_init_header(OpenBLAS32_jll, NetCDF_jll)
    JLLWrappers.@init_library_product(
        libTempestRemap,
        "lib/libTempestRemap.0.dylib",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_executable_product(
        AnalyzeMap_exe,
        "bin/AnalyzeMap",
    )

    JLLWrappers.@init_executable_product(
        ApplyOfflineMap_exe,
        "bin/ApplyOfflineMap",
    )

    JLLWrappers.@init_executable_product(
        CalculateDiffNorms_exe,
        "bin/CalculateDiffNorms",
    )

    JLLWrappers.@init_executable_product(
        CoarsenRectilinearData_exe,
        "bin/CoarsenRectilinearData",
    )

    JLLWrappers.@init_executable_product(
        GenerateCSMesh_exe,
        "bin/GenerateCSMesh",
    )

    JLLWrappers.@init_executable_product(
        GenerateGLLMetaData_exe,
        "bin/GenerateGLLMetaData",
    )

    JLLWrappers.@init_executable_product(
        GenerateICOMesh_exe,
        "bin/GenerateICOMesh",
    )

    JLLWrappers.@init_executable_product(
        GenerateLambertConfConicMesh_exe,
        "bin/GenerateLambertConfConicMesh",
    )

    JLLWrappers.@init_executable_product(
        GenerateOfflineMap_exe,
        "bin/GenerateOfflineMap",
    )

    JLLWrappers.@init_executable_product(
        GenerateOverlapMesh_exe,
        "bin/GenerateOverlapMesh",
    )

    JLLWrappers.@init_executable_product(
        GenerateOverlapMesh_v1_exe,
        "bin/GenerateOverlapMesh_v1",
    )

    JLLWrappers.@init_executable_product(
        GenerateRLLMesh_exe,
        "bin/GenerateRLLMesh",
    )

    JLLWrappers.@init_executable_product(
        GenerateRectilinearMeshFromFile_exe,
        "bin/GenerateRectilinearMeshFromFile",
    )

    JLLWrappers.@init_executable_product(
        GenerateStereographicMesh_exe,
        "bin/GenerateStereographicMesh",
    )

    JLLWrappers.@init_executable_product(
        GenerateTestData_exe,
        "bin/GenerateTestData",
    )

    JLLWrappers.@init_executable_product(
        GenerateTransectMesh_exe,
        "bin/GenerateTransectMesh",
    )

    JLLWrappers.@init_executable_product(
        GenerateTransposeMap_exe,
        "bin/GenerateTransposeMap",
    )

    JLLWrappers.@init_executable_product(
        GenerateUTMMesh_exe,
        "bin/GenerateUTMMesh",
    )

    JLLWrappers.@init_executable_product(
        GenerateVolumetricMesh_exe,
        "bin/GenerateVolumetricMesh",
    )

    JLLWrappers.@init_executable_product(
        MeshToTxt_exe,
        "bin/MeshToTxt",
    )

    JLLWrappers.@init_executable_product(
        RestructureData_exe,
        "bin/RestructureData",
    )

    JLLWrappers.@init_executable_product(
        ShpToMesh_exe,
        "bin/ShpToMesh",
    )

    JLLWrappers.@init_executable_product(
        VerticalInterpolate_exe,
        "bin/VerticalInterpolate",
    )

    JLLWrappers.@generate_init_footer()
end  # __init__()

ext: jl


text:
using TracedRandom, Random, Test

@testset "Addressed function calls" begin

gaussian_mixture(μs) = randn(:z) + μs[rand(:k, 1:length(μs))]
Random.seed!(0)
traced = rand(:y, gaussian_mixture, [1, 10, 100])
Random.seed!(0)
untraced = gaussian_mixture([1, 10, 100])
@test traced == untraced

Random.seed!(0)
traced = rand(here, gaussian_mixture, [1, 10, 100])
Random.seed!(0)
untraced = gaussian_mixture([1, 10, 100])
@test traced == untraced

end

@testset "Addressed calls with global RNG" begin

for fn in (rand, randn, randexp, bitrand, randstring)
   Random.seed!(0)
   traced = fn(:addr)
   Random.seed!(0)
   untraced = fn()
   @test traced == untraced
end

for fn in (rand!, randn!, randexp!)
   Random.seed!(0)
   traced = fn(:addr => :subaddr, zeros(5))
   Random.seed!(0)
   untraced = fn(zeros(5))
   @test traced == untraced
end

for fn in (randperm, randcycle)
   Random.seed!(0)
   traced = fn(:addr, 5)
   Random.seed!(0)
   untraced = fn(5)
   @test traced == untraced
end

for fn in (randperm!, randcycle!)
   Random.seed!(0)
   traced = fn(:addr => 0, Vector{Int}(undef, 5))
   Random.seed!(0)
   untraced = fn(Vector{Int}(undef, 5))
   @test traced == untraced
end

Random.seed!(0)
traced = shuffle(:addr, [1, 2, 3, 4, 5])
Random.seed!(0)
untraced = shuffle([1, 2, 3, 4, 5])
@test traced == untraced

Random.seed!(0)
traced = shuffle!(:addr, [1, 2, 3, 4, 5])
Random.seed!(0)
untraced = shuffle!([1, 2, 3, 4, 5])
@test traced == untraced

Random.seed!(0)
traced = randsubseq(:addr, [1, 2, 3, 4, 5], 0.2)
Random.seed!(0)
untraced = randsubseq([1, 2, 3, 4, 5], 0.2)
@test traced == untraced

Random.seed!(0)
traced = randsubseq!(:addr, [], [1, 2, 3, 4, 5], 0.2)
Random.seed!(0)
untraced = randsubseq!([], [1, 2, 3, 4, 5], 0.2)
@test traced == untraced

end

@testset "Addressed calls with custom RNG" begin

rng = MersenneTwister()

for fn in (rand, randn, randexp, bitrand, randstring)
   Random.seed!(rng, 42)
   traced = fn(rng, :addr)
   Random.seed!(rng, 42)
   untraced = fn(rng)
   @test traced == untraced
end

for fn in (rand!, randn!, randexp!)
   Random.seed!(rng, 42)
   traced = fn(rng, :addr => :subaddr, zeros(5))
   Random.seed!(rng, 42)
   untraced = fn(rng, zeros(5))
   @test traced == untraced
end

for fn in (randperm, randcycle)
   Random.seed!(rng, 42)
   traced = fn(rng, :addr, 5)
   Random.seed!(rng, 42)
   untraced = fn(rng, 5)
   @test traced == untraced
end

for fn in (randperm!, randcycle!)
   Random.seed!(rng, 42)
   traced = fn(rng, :addr => 0, Vector{Int}(undef, 5))
   Random.seed!(rng, 42)
   untraced = fn(rng, Vector{Int}(undef, 5))
   @test traced == untraced
end

Random.seed!(rng, 42)
traced = shuffle(rng, :addr, [1, 2, 3, 4, 5])
Random.seed!(rng, 42)
untraced = shuffle(rng, [1, 2, 3, 4, 5])
@test traced == untraced

Random.seed!(rng, 42)
traced = shuffle!(rng, :addr, [1, 2, 3, 4, 5])
Random.seed!(rng, 42)
untraced = shuffle!(rng, [1, 2, 3, 4, 5])
@test traced == untraced

Random.seed!(rng, 42)
traced = randsubseq(rng, :addr, [1, 2, 3, 4, 5], 0.2)
Random.seed!(rng, 42)
untraced = randsubseq(rng, [1, 2, 3, 4, 5], 0.2)
@test traced == untraced

Random.seed!(rng, 42)
traced = randsubseq!(rng, :addr, [], [1, 2, 3, 4, 5], 0.2)
Random.seed!(rng, 42)
untraced = randsubseq!(rng, [], [1, 2, 3, 4, 5], 0.2)
@test traced == untraced

end


text:
using FastGroupBy
const M = 100_000_000 # data.table takes 12 seconds
const K = 100
srand(1)
const svec = rand(["id"*dec(k,10) for k in 1:M÷K], M)


text:
module ContinuedFraction

importall Base

export PartialQuotients,
       Convergents,
       qi_sqrt

include("quadraticirrational.jl")
include("partialquotients.jl")
include("periods.jl")
include("convergents.jl")

end # module


text:
using Meshing
using Base.Test
using GeometryTypes

# Produce a level set function that is a noisy version of the distance from
# the origin (such that level sets are noisy spheres).
#
# The noise should exercise marching tetrahedra's ability to produce a water-
# tight surface in all cases (unlike standard marching cubes).
#
N = 10
sigma = 1.0
distance = Float32[ sqrt(Float32(i*i+j*j+k*k)) for i = -N:N, j = -N:N, k = -N:N ]
distance = distance + sigma*rand(2*N+1,2*N+1,2*N+1)

# Extract an isosurface.
#
lambda = N-2*sigma # isovalue

msh = HomogenousMesh(distance,lambda)

s2 = SignedDistanceField(HyperRectangle(Vec(0,0,0.),Vec(1,1,1.))) do v
    sqrt(sum(dot(v,v))) - 1 # sphere
end

msh = HomogenousMesh(s2)
@test length(vertices(msh)) == 973
@test length(faces(msh)) == 1830

# Vertex interpolation
@test Meshing.vertex_interp(0, Vec(0,0,0), Vec(0,1,0), -1, 1) == Vec(0,0.5,0)
@test Meshing.vertex_interp(-1, Vec(0,0,0), Vec(0,1,0), -1, 1) == Vec(0,0,0)
@test Meshing.vertex_interp(1, Vec(0,0,0), Vec(0,1,0), -1, 1) == Vec(0,1,0)

# marching cubes
sdf = SignedDistanceField(HyperRectangle(Vec(-1,-1,-1.),Vec(2,2,2.))) do v
    sqrt(sum(dot(v,v))) - 1 # sphere
end

m = marching_cubes(sdf,0)
m2 = marching_cubes(sdf)
@test length(vertices(m)) == 10968
@test length(faces(m)) == 3656
@test m == m2

if "--profile" in ARGS
    HomogenousMesh(s2)
    Profile.clear()
    @profile HomogenousMesh(s2)
    #ProfileView.view()
end


text:
module PointProcess

# Write your package code here.
    # install necessary packages (open source)
    using Statistics, Plots, Distributions , LinearAlgebra

    # install necessary packages (original)
    using .FundamentalStats
    export EmpiricalFireRate
    export MakeWindow
    export FanoFactor
    function MakeWindow(t::Vector=[nothing],s = 0., f = nothing , delta = 1.;
                    data::Vector = t, start = s, finish = f , dt = delta)::Taple{Vector{Float64},Vector{Int64}}
        if finish == nothing
            finish = t[end]
        end
        T::Vector{Float64} = collect(start:dt:finish)
        N::Vector{Int64} = [sum( (data.>= i) .& (data.< i+dt) ) for i in T]
        return T, N
    end

    function EmpiricalFireRate(t::Vector=[nothing],s = 0., f = nothing , delta = 1.;
                    data::Vector = t, start = s, finish = f , dt = delta)::Taple{Vector{Float64},Vector{Float64}}
        X::Vector{Float64},Y::Vector{Float64} = MakeWindow(data = data, start = start, finish = finish, dt = dt)
        return X, Y./dt
    end
    function FanoFactor(t::Vector = [nothing], s = 0., f = nothing, delta = 1.;
                            data::Vector = t, start = s, finish = f , dt = delta)::Float64
        _, Y::Vector{Float64} = MakeWindow(data = data, start = start, finish = finish, dt = dt)
        return var(Y)/mean(Y)
    end

end

max_stars_repo_name: yukki-jpn/JuliaTSA

max_issues_repo_name: yukki-jpn/JuliaTSA

max_forks_repo_name: yukki-jpn/JuliaTSA


text:
export glorot_uniform, glorot_normal, orthogonal

import Flux: glorot_uniform, glorot_normal

using Random
using LinearAlgebra

# https://github.com/FluxML/Flux.jl/pull/1171/
# https://www.tensorflow.org/api_docs/python/tf/keras/initializers/Orthogonal
function orthogonal_matrix(rng::AbstractRNG, nrow, ncol)
    shape = reverse(minmax(nrow, ncol))
    a = randn(rng, Float32, shape)
    q, r = qr(a)
    q = Matrix(q) * diagm(sign.(diag(r)))
    nrow < ncol ? permutedims(q) : q
end

function orthogonal(rng::AbstractRNG, d1, rest_dims...)
    m = orthogonal_matrix(rng, d1, *(rest_dims...))
    reshape(m, d1, rest_dims...)
end

orthogonal(dims...) = orthogonal(Random.GLOBAL_RNG, dims...)
orthogonal(rng::AbstractRNG) = (dims...) -> orthogonal(rng, dims...)

function batch!(data, xs)
    for (i, x) in enumerate(xs)
        data[Flux.batchindex(data, i)...] = x
    end
    data
end


text:
module Unfold

using PyMNE
using SparseArrays
using StatsModels
using StatsBase
using IterativeSolvers
using DataFrames
using MixedModels
using Missings
using StatsBase
using LinearAlgebra
using Tables # not sure we need it
using GLM # not sure we need it
import MixedModels.FeMat # extended for sparse femats, type piracy => issue on MixedModels.jl github
using TimerOutputs # debugging fitting times etc. not strictly needed
using DSP
using StatsModels
using StaticArrays # for MixedModels extraction of parametrs (inherited from MixedModels.jl, not strictly needed )
using ProgressMeter
using DocStringExtensions # for Docu
using MLBase # for crossVal
using BSplines # for spline predictors
import StatsBase: fit

#using IncompleteLU
import Base.(+) # overwrite for DesignMatrices
using Distributions: Gamma, pdf # TODO replace this with direct implementation (used in basisfunction.jl)

include("basisfunctions.jl")
include("designmatrix.jl")
include("linearmodels.jl")
include("fit.jl")
include("utilities.jl")
include("condense.jl")
include("solver.jl")
include("predict.jl")
include("splinepredictors.jl")
include("clusterpermutation.jl")
#include("plot.jl") # don't include for now
export fit, designmatrix, firbasis,hrfbasis,condense_long,UnfoldLinearModel,UnfoldLinearMixedModel
export unfoldfit # might be renamend to fit! in the future
export predict,spl
export cluster_permutation_test
end # module


text:
using TheAlgorithms
using Documenter

DocMeta.setdocmeta!(TheAlgorithms, :DocTestSetup, :(using TheAlgorithms); recursive=true)

makedocs(;
    modules=[TheAlgorithms],
    authors="Panquesito7",
    repo="https://github.com/TheAlgorithms/Julia/blob/{commit}{path}#{line}",
    sitename="TheAlgorithms.jl",
    format=Documenter.HTML(;
        prettyurls=get(ENV, "CI", "false") == "true",
        canonical="https://TheAlgorithms.github.io/Julia",
        assets=String[],
    ),
    pages=[
        "Home" => "index.md",
    ],
)

deploydocs(;
    repo="github.com/TheAlgorithms/Julia",
    devbranch="main",
)

max_stars_repo_name: KohRongSoon/Julia

max_issues_repo_name: KohRongSoon/Julia

max_forks_repo_name: KohRongSoon/Julia


text:
#
# Tests for the K-Profile-Parameterization
#

function test_constants(; kwargs...)
    constants = KPP.Constants(; kwargs...)
    result = true
    for (k, v) in kwargs
        if result
            result = getproperty(constants, k) == v
        end
    end
    return result
end

function test_model_init(N=4, L=4.3)
    model = KPP.Model(N=N, L=L)
    model.grid.N == N && model.grid.L == L
end

addone(m, i) = 1

function test_model_init_with_forcing(N=4, L=4.3)
    model = KPP.Model(N=N, L=L, forcing=KPP.Forcing(U=addone))
    model.grid.N == N && model.grid.L == L
end

function test_surface_layer_average_simple(;
    N = 10,
    L = 1.1,
    i = 9
    )

    model = KPP.Model(N=N, L=L)

    T_test = 2.1
    model.solution.T = T_test

    CSLs = [0.01, 0.1, 0.3, 0.5, 1.0]
    avg = zeros(length(CSLs))
    for (j, CSL) in enumerate(CSLs)
        avg[j] = KPP.surface_layer_average(model.solution.T, CSL, i)
    end

    !any(@. !isapprox(avg, T_test))
end

function test_surface_layer_average_linear(; N=10, L=4.1, γ=7.9)
    CSL = 1.0 # test only works with full depth layer fraction
    model = KPP.Model(N=N, L=L)
    T_test(z) = γ*z
    model.solution.T = T_test

    avg = FaceField(model.grid)

    for i = 1:N
        avg[i] = KPP.surface_layer_average(model.solution.T, CSL, i)
    end

    h = -model.grid.zf
    avg_answer = @. -0.5 * γ * CSL * h
    isapprox(avg.data, avg_answer)
end

function analytical_surface_layer_average()
    CSL, N, L = 0.5, 10, 10.0
    T, avg = zeros(N), zeros(N+1)

    T[1:8] .= 0
    T[9] = 2
    T[10] = 3

    avg[1:7] .= [10 / (11-i) for i=1:7]
    avg[8] = 4/1.5
    avg[9:10] .= 3
    avg[11] = 0.0

    return CSL, N, L, T, avg
end

function test_surface_layer_average_steps()
    CSL, N, L, T, avg_answer = analytical_surface_layer_average()
    model = KPP.Model(N=N, L=L)
    model.solution.T = T

    avg = zeros(N+1)
    for i = 1:N
        avg[i] = KPP.surface_layer_average(model.solution.T, CSL, i)
    end

    avg ≈ avg_answer
end

function test_surface_layer_average_epsilon(; γ=2.1, CSL=0.01, N=10, L=1.0, T₀₀=281.2)
    T₀(z) = T₀₀*γ*z
    model = KPP.Model(N=N, L=L)
    model.solution.T = T₀

    i = 2
    h = -model.grid.zf[i]
    avg = KPP.surface_layer_average(model.solution.T, CSL, i)
    avg_answer = T₀(-model.grid.Δf/2)

    avg ≈ avg_answer
end

function test_Δ0()
    model = KPP.Model()
    (KPP.Δ(model.solution.U, 0.01, 2) == 0 &&
     KPP.Δ(model.solution.V, 0.01, 2) == 0 &&
     KPP.Δ(model.solution.T, 0.01, 2) == 0 &&
     KPP.Δ(model.solution.S, 0.01, 2) == 0)
end

function test_Δ1()
    CSL, N, L, T, surf_avg = analytical_surface_layer_average()
    parameters = KPP.Parameters(CSL=CSL)
    model = KPP.Model(N=N, L=L, parameters=parameters)
    model.solution.T = T

    Δ_lower = surf_avg[2]
    Δ_upper = surf_avg[10] - 2.5

    KPP.Δ(model.solution.T, CSL, 2) == Δ_lower && KPP.Δ(model.solution.T, CSL, 10) == Δ_upper
end

function test_Δ2(; γ=2.1, CSL=0.001, N=10, L=1.0, i=N)
    model = KPP.Model(N=N, L=L)
    T₀(z) = γ*z
    model.solution.T = T₀
    T = model.solution.T
    h = -model.grid.zf[i]
    Δ_answer = T[N] - T₀(-h)
    KPP.Δ(model.solution.T, CSL, i) ≈ Δ_answer
end

function test_Δ3(; CSL=0.5, N=20, L=20)
    U₀ = 3
    parameters = KPP.Parameters(CSL=CSL)
    model = KPP.Model(N=N, L=L, parameters=parameters)
    U, V, T, S = model.solution

    ih = 12
    @views U.data[ih:N] .= U₀
    @views U.data[1:ih-1] .= -U₀

    KPP.Δ(U, CSL, ih) == U₀
end

function test_buoyancy_gradient(; γ=0.01, g=9.81, ρ₀=1028, α=2e-4, β=0.0, N=10, L=1.0)
    model = KPP.Model(N=N, L=L)
    T₀(z) = γ*z
    model.solution.T = T₀
    Bz_answer = g * α * γ
    Bz = KPP.∂B∂z(model.solution.T, model.solution.S, g, α, β, 3)
    return Bz ≈ Bz_answer
end

function test_unresolved_KE(; CKE=0.1, CKE₀=1e-11, Qb=1e-7, γ=0.01, g=9.81,
                                ρ₀=1028, α=2e-4, β=0.0, N=10, L=1.0)
    Bz = g * α * γ
    T₁(z) = γ*z
    T₂(z) = -γ*z
    model = KPP.Model(N=N, L=L)
    U, V, T, S = model.solution

    i = 2
    h = -model.grid.zf[i]

    # Test for Bz > 0
    model.solution.T = T₁
    Bz = KPP.∂B∂z(T, S, model.constants.g, model.constants.α, model.constants.β, i)
    ke₁ = KPP.unresolved_kinetic_energy(h, Bz, Qb, CKE, CKE₀, g, α, β)
    ke₁_answer = CKE * h^(4/3) * sqrt(Bz) * Qb^(1/3) + CKE₀

    # Test for Bz < 0
    model.solution.T = T₂
    Bz = KPP.∂B∂z(T, S, model.constants.g, model.constants.α, model.constants.β, i)
    ke₂ = KPP.unresolved_kinetic_energy(h, Bz, Qb, CKE, CKE₀, g, α, β)
    ke₂_answer = CKE₀

    return ke₂ ≈ ke₂_answer && ke₁ ≈ ke₁_answer
end

function test_update_state(; N=10, L=20, Qθ=5.1e-3)
    model = KPP.Model(N=N, L=L)
    temperature_bc = FluxBoundaryCondition(Qθ)
    model.bcs.T.top = temperature_bc

    KPP.update_state!(model)

    return model.state.Qθ == Qθ
end

function test_bulk_richardson_number(; g=9.81, α=2.1e-4, CRi=0.3, CKE=1.04,
                                       CKE₀=0.0, γ=0.01, N=20, L=20, Qb=2.1e-5)
    parameters = KPP.Parameters(CRi=CRi, CKE=CKE, CKE₀=CKE₀, CSL=0.1/N)
    constants = KPP.Constants(g=g, α=α)
    model = KPP.Model(N=N, L=L, parameters=parameters, constants=constants)
    U, V, T, S = model.solution

    # Initial condition and top flux
    T₀(z) = γ*z
    model.solution.T = T₀

    # "Surface" temperature and buoyancy
    T_N = T[N]
    B_N = g*α*T[N]

    Qθ = Qb / (g*α)
    top_bc_T = FluxBoundaryCondition(Qθ)
    model.bcs.T.top = top_bc_T
    KPP.update_state!(model)

    Ri = FaceField(model.grid)
    Ri_answer = FaceField(model.grid)
    for i = interiorindices(Ri)
        Ri[i] = KPP.bulk_richardson_number(model, i)

        h = - model.grid.zf[i]
        h⁺ = h * (1 - 0.5*model.parameters.CSL)
        Bz = KPP.∂B∂z(T, S, model.constants.g, model.constants.α, model.constants.β, i)
        uke = KPP.unresolved_kinetic_energy(h, Bz, Qb, CKE, CKE₀, g, α, model.constants.β)
        Ri_answer[i] = h⁺ * (B_N - g*α*T₀(-h)) / uke
    end

    isapprox(Ri_answer.data, Ri.data)
end

function test_mixing_depth_convection(; g=9.81, α=2.1e-4, CRi=0.3, CKE=1.04,
                                       γ=0.01, N=200, L=20, Qb=4.1e-5)
    parameters = KPP.Parameters(CRi=CRi, CKE=CKE, CKE₀=0.0, CSL=0.1/N)
    constants = KPP.Constants(g=g, α=α)
    model = KPP.Model(N=N, L=L, parameters=parameters, constants=constants)
    U, V, T, S = model.solution

    T₀(z) = γ*z
    model.solution.T = T₀
    model.solution.T[N] = 0

    Qθ = Qb / (g*α)
    temperature_bc = FluxBoundaryCondition(Qθ)
    model.bcs.T.top = temperature_bc
    KPP.update_state!(model)

    Ri = FaceField(model.grid)
    for i = interiorindices(Ri)
        Ri[i] = KPP.bulk_richardson_number(model, i)
    end

    h = KPP.mixing_depth(model)
    h_answer = (CRi*CKE)^(3/2) * (α*g*γ)^(-3/4) * sqrt(Qb) / (1 - 0.5*model.parameters.CSL)

    isapprox(h, h_answer, rtol=1e-3)
end

function test_mixing_depth_shear(; CSL=0.5, N=20, L=20, CRi=1.0)
    T₀ = 1
    U₀ = 3
    parameters = KPP.Parameters(CRi=CRi, CSL=CSL, CKE₀=0.0)
    constants = KPP.Constants(g=1, α=1)
    model = KPP.Model(N=N, L=L, parameters=parameters, constants=constants)
    U, V, T, S = model.solution

    h = CRi * U₀^2 / T₀ / (1 - 0.5*model.parameters.CSL)
    ih = Int(N*(1 - h/L) + 1)
    @views T.data[ih:N] .= T₀
    @views U.data[ih:N] .= U₀

    @views T.data[1:ih-1] .= -T₀
    @views U.data[1:ih-1] .= -U₀

    KPP.mixing_depth(model) ≈ h
end

function test_unstable()
    model = KPP.Model()

    model.bcs.T.top = FluxBoundaryCondition(1)
    KPP.update_state!(model)
    stability₊ = KPP.isunstable(model)

    model.bcs.T.top = FluxBoundaryCondition(-1)
    KPP.update_state!(model)
    stability₋ = KPP.isunstable(model)

    stability₊ == true && stability₋ == false
end

function test_zero_turbulent_velocity()
    model = KPP.Model()
    KPP.ωτ(model) == 0.0 &&  KPP.ωb(model) == 0.0
end

function test_friction_velocity()
    model = KPP.Model()
    model.bcs.U.top = FluxBoundaryCondition(sqrt(8))
    model.bcs.V.top = FluxBoundaryCondition(-sqrt(8))
    KPP.update_state!(model)
    KPP.ωτ(model) ≈ 2
end

function test_convective_velocity()
    model = KPP.Model()
    γ = 0.01
    T₀(z) = γ*z
    model.solution.T = T₀

    Qb = 2.1
    Qθ = Qb / (model.constants.α*model.constants.g)
    model.bcs.T.top = FluxBoundaryCondition(Qθ)
    KPP.update_state!(model)

    h = KPP.mixing_depth(model)

    KPP.ωb(model) ≈ (h*Qb)^(1/3)
end

function test_turb_velocity_pure_convection(N=20, L=20, Cb_U=3.1, Cb_T=1.7, CSL=1e-16)
    # Zero wind + convection => 𝒲_U = Cb_U * CSL^(1/3) * ωb.
    parameters = KPP.Parameters(CRi=1.0, CKE=1.0, CKE₀=0.0, CSL=CSL, Cb_U=Cb_U, Cb_T=Cb_T)
    constants = KPP.Constants(g=1, α=1)
    model = KPP.Model(N=N, L=L, parameters=parameters, constants=constants)
    U, V, T, S = model.solution

    T₀(z) = z
    model.solution.T = T₀
    model.solution.T[N] = 0

    Qb = 100
    model.bcs.T.top = FluxBoundaryCondition(Qb)
    KPP.update_state!(model)

    i = 16
    h = sqrt(Qb) / (1-0.5CSL) # requires h to be an integer... ?
    ωb = (h*Qb)^(1/3)

    (KPP.𝒲_U(model, i) ≈ Cb_U * CSL^(1/3) * ωb &&
     KPP.𝒲_V(model, i) ≈ Cb_U * CSL^(1/3) * ωb &&
     KPP.𝒲_T(model, i) ≈ Cb_T * CSL^(1/3) * ωb &&
     KPP.𝒲_S(model, i) ≈ Cb_T * CSL^(1/3) * ωb )
end

function test_turb_velocity_pure_wind(; CSL=0.5, Cτ=0.7, N=20, L=20, CRi=1.0)
    T₀ = 1
    U₀ = 3
    parameters = KPP.Parameters(CRi=CRi, Cτ=Cτ, CSL=CSL)
    constants = KPP.Constants(g=1, α=1)
    model = KPP.Model(N=N, L=L, parameters=parameters, constants=constants)
    U, V, T, S = model.solution

    h = CRi * U₀^2 / T₀
    ih = Int(N*(1 - h/L) + 1)
    @views T.data[ih:N] .= T₀
    @views U.data[ih:N] .= U₀

    @views T.data[1:ih-1] .= -T₀
    @views U.data[1:ih-1] .= -U₀

    Qu = 2.1
    model.bcs.U.top = FluxBoundaryCondition(Qu)
    KPP.update_state!(model)

    𝒲 = Cτ * sqrt(Qu)

    (KPP.𝒲_U(model, 3) == 𝒲 &&
     KPP.𝒲_V(model, 3) == 𝒲 &&
     KPP.𝒲_T(model, 3) == 𝒲 &&
     KPP.𝒲_S(model, 3) == 𝒲 )
end

function test_turb_velocity_wind_stab(; CSL=0.5, Cτ=0.7, N=20, L=20, CRi=1.0, Cstab=0.3)
    T₀ = 1
    U₀ = 3
    parameters = KPP.Parameters(CRi=CRi, Cτ=Cτ, CSL=CSL, Cstab=Cstab)
    constants = KPP.Constants(g=1, α=1)
    model = KPP.Model(N=N, L=L, parameters=parameters, constants=constants)
    U, V, T, S = model.solution

    h = CRi * U₀^2 / T₀
    ih = Int(N*(1 - h/L) + 1) # 12
    @views T.data[ih:N] .= T₀
    @views U.data[ih:N] .= U₀

    @views T.data[1:ih-1] .= -T₀
    @views U.data[1:ih-1] .= -U₀

    Qu = 2.1
    model.bcs.U.top = FluxBoundaryCondition(Qu)
    Qθ = -1.3
    model.bcs.T.top = FluxBoundaryCondition(Qθ)
    KPP.update_state!(model)

    rb = abs(h*Qθ) / Qu^(3/2)

    id = 16 # d=5/9
    d = 5/9
    𝒲 = Cτ * sqrt(Qu) / (1 + Cstab * rb * d)

    (KPP.𝒲_U(model, id) ≈ 𝒲 &&
     KPP.𝒲_V(model, id) ≈ 𝒲 &&
     KPP.𝒲_T(model, id) ≈ 𝒲 &&
     KPP.𝒲_S(model, id) ≈ 𝒲 )
end

function test_turb_velocity_wind_unstab(; CKE=0.0, CSL=0.5, Cτ=0.7, N=20,
                                        L=20, CRi=(1-0.5CSL), Cunst=0.3)
    T₀ = 1
    U₀ = 3
    parameters = KPP.Parameters(CRi=CRi, Cτ=Cτ, CKE=CKE, CKE₀=0.0,
                                CSL=CSL, Cunst=Cunst, Cd_U=Inf, Cd_T=Inf)
    constants = KPP.Constants(g=1, α=1)
    model = KPP.Model(N=N, L=L, parameters=parameters, constants=constants)
    U, V, T, S = model.solution

    h = CRi * U₀^2 / T₀ / (1-0.5CSL)
    ih = Int(N*(1 - h/L) + 1) # 12
    @views T.data[ih:N] .= T₀
    @views U.data[ih:N] .= U₀

    @views T.data[1:ih-1] .= -T₀
    @views U.data[1:ih-1] .= -U₀

    Qu = 2.1
    model.bcs.U.top = FluxBoundaryCondition(Qu)
    Qθ = 1.1
    model.bcs.T.top = FluxBoundaryCondition(Qθ)
    KPP.update_state!(model)

    rb = abs(h*Qθ) / (Qu)^(3/2)
    id1 = 16 # d=5/9
    id2 = 18 # d=3/9
    d1 = 5/9
    d2 = 3/9

    𝒲_U1 = Cτ * sqrt(Qu) * (1 + Cunst * rb * CSL)^(1/4)
    𝒲_T1 = Cτ * sqrt(Qu) * (1 + Cunst * rb * CSL)^(1/2)

    𝒲_U2 = Cτ * sqrt(Qu) * (1 + Cunst * rb * d2)^(1/4)
    𝒲_T2 = Cτ * sqrt(Qu) * (1 + Cunst * rb * d2)^(1/2)

    (KPP.𝒲_U(model, id1) ≈ 𝒲_U1 &&
     KPP.𝒲_V(model, id1) ≈ 𝒲_U1 &&
     KPP.𝒲_T(model, id1) ≈ 𝒲_T1 &&
     KPP.𝒲_S(model, id1) ≈ 𝒲_T1 &&
     KPP.𝒲_U(model, id2) ≈ 𝒲_U2 &&
     KPP.𝒲_V(model, id2) ≈ 𝒲_U2 &&
     KPP.𝒲_T(model, id2) ≈ 𝒲_T2 &&
     KPP.𝒲_S(model, id2) ≈ 𝒲_T2 )
end

function test_conv_velocity_wind(; CKE=0.0, CKE₀=0.0, CSL=0.5, Cτ=0.7, N=20, L=20, CRi=(1-0.5CSL),
                                 Cb_U=1.1, Cb_T=0.1)
    T₀ = 1
    U₀ = 3

    parameters = KPP.Parameters(CRi=CRi, Cτ=Cτ, CKE=CKE, CKE₀=0.0, CSL=CSL, Cd_U=0.0, Cd_T=0.0,
                                Cb_U=1.1, Cb_T=0.1)

    constants = KPP.Constants(g=1, α=1)
    model = KPP.Model(N=N, L=L, parameters=parameters, constants=constants)
    U, V, T, S = model.solution

    h = CRi * U₀^2 / T₀ / (1-0.5CSL)
    ih = Int(N*(1 - h/L) + 1) # 12
    @views T.data[ih:N] .= T₀
    @views U.data[ih:N] .= U₀

    @views T.data[1:ih-1] .= -T₀
    @views U.data[1:ih-1] .= -U₀

    Qu = -2.1
    model.bcs.U.top = FluxBoundaryCondition(Qu)
    Qθ = 0.5
    model.bcs.T.top = FluxBoundaryCondition(Qθ)
    KPP.update_state!(model)

    rb = abs(h*Qθ) / abs(Qu)^(3/2)
    rτ = 1/rb
    id1 = 16 # d=5/9
    id2 = 18 # d=3/9
    d1 = 5/9
    d2 = 3/9

    Cτb_U = model.parameters.Cτb_U
    Cτb_T = model.parameters.Cτb_T

    𝒲_U1 = Cb_U * abs(h*Qθ)^(1/3) * (CSL + Cτb_U * rτ)^(1/3)
    𝒲_T1 = Cb_T * abs(h*Qθ)^(1/3) * (CSL + Cτb_T * rτ)^(1/3)

    𝒲_U2 = Cb_U * abs(h*Qθ)^(1/3) * (d2 + Cτb_U * rτ)^(1/3)
    𝒲_T2 = Cb_T * abs(h*Qθ)^(1/3) * (d2 + Cτb_T * rτ)^(1/3)

    return (KPP.𝒲_U(model, id1) ≈ 𝒲_U1 &&
            KPP.𝒲_V(model, id1) ≈ 𝒲_U1 &&
            KPP.𝒲_T(model, id1) ≈ 𝒲_T1 &&
            KPP.𝒲_S(model, id1) ≈ 𝒲_T1 &&
            KPP.𝒲_U(model, id2) ≈ 𝒲_U2 &&
            KPP.𝒲_V(model, id2) ≈ 𝒲_U2 &&
            KPP.𝒲_T(model, id2) ≈ 𝒲_T2 &&
            KPP.𝒲_S(model, id2) ≈ 𝒲_T2 )
end

function test_diffusivity_plain(; K₀=1.1)
    parameters = KPP.Parameters(KU₀=K₀, KT₀=K₀, KS₀=K₀)
    model = KPP.Model(parameters=parameters)
    KPP.update_state!(model)

    m = model
    KU = FaceField(model.grid)
    KV = FaceField(model.grid)
    KT = FaceField(model.grid)
    KS = FaceField(model.grid)
    for i = 1:model.grid.N+1
        KU[i] = KPP.KU(model, i)
        KV[i] = KPP.KV(model, i)
        KT[i] = KPP.KT(model, i)
        KS[i] = KPP.KS(model, i)
    end

    return (!any(@. KU.data != K₀) &&
            !any(@. KV.data != K₀) &&
            !any(@. KT.data != K₀) &&
            !any(@. KS.data != K₀) )
end

function test_kpp_diffusion_cosine(stepper=:ForwardEuler)
    parameters = KPP.Parameters(KT₀=1.0, KS₀=1.0)
    model = KPP.Model(N=100, L=π/2, parameters=parameters, stepper=stepper)
    z = model.grid.zc

    c_init(z) = cos(2z)
    c_ans(z, t) = exp(-4t) * c_init(z)

    model.solution.T = c_init
    model.solution.S = c_init

    KPP.update_state!(model)
    U, V, T, S = model.solution

    m = model
    i = 3
    dt = 1e-3
    iterate!(model, dt)

    # The error tolerance is a bit arbitrary.
    return norm(c_ans.(z, time(model)) .- data(model.solution.T)) < model.grid.N*1e-6
end

function test_flux(stepper=:ForwardEuler; fieldname=:U, top_flux=0.3, bottom_flux=0.13, N=10)
    model = KPP.Model(N=N, L=1, stepper=stepper)

    bcs = getproperty(model.bcs, fieldname)
    bcs.top = FluxBoundaryCondition(top_flux)
    bottom_K = getproperty(model.timestepper.eqn.K, fieldname)(model, 1)
    bcs.bottom = GradientBoundaryCondition(-bottom_flux / bottom_K)

    c = getproperty(model.solution, fieldname)
    C₀ = integral(c)
    C(t) = C₀ - (top_flux - bottom_flux) * t

    dt = 1e-6
    iterate!(model, dt, 10)

    return C(time(model)) ≈ integral(c)
end

function test_nonlocal_salinity_flux_util(N=4, L=4.3)
    model = KPP.Model(N=N, L=L)

    try
        flux = KPP.nonlocal_salinity_flux(model)
    catch err
        @error sprint(showerror, err)
        return false
    end

    return true
end

function test_nonlocal_temperature_flux_util(N=4, L=4.3)
    model = KPP.Model(N=N, L=L)

    try
        flux = KPP.nonlocal_temperature_flux(model)
    catch err
        @error sprint(showerror, err)
        return false
    end

    return true
end

@testset "KPP" begin
    @test test_constants(g=9.81, α=2.1e-4, ρ₀=1028.1, β=0.99, cP=3904.1, f=1e-4)
    @test test_model_init()
    @test test_model_init_with_forcing()
    @test test_buoyancy_gradient()
    @test test_unresolved_KE()
    @test test_surface_layer_average_simple()
    @test test_surface_layer_average_linear()
    @test test_surface_layer_average_steps()
    @test test_surface_layer_average_epsilon()
    @test test_update_state()
    @test test_Δ0()
    @test test_Δ1()

    N = 10
    @test test_Δ2(N=N, i=N-2)
    @test test_Δ2(N=N, i=N-1)
    @test test_Δ2(N=N, i=N)
    @test test_Δ3()

    @test test_buoyancy_gradient()
    @test test_unresolved_KE()
    @test test_bulk_richardson_number()

    @test test_mixing_depth_convection()
    @test test_mixing_depth_shear()

    @test test_unstable()
    @test test_zero_turbulent_velocity()
    @test test_friction_velocity()
    @test test_convective_velocity()

    @test test_turb_velocity_pure_convection()
    @test test_turb_velocity_pure_wind()
    @test test_turb_velocity_wind_stab()
    @test test_turb_velocity_wind_unstab()
    @test test_conv_velocity_wind()

    @test test_diffusivity_plain()

    for stepper in steppers
        @test test_kpp_diffusion_cosine(stepper)
        for fieldname in (:U, :V, :T, :S)
            for top_flux in (0.3, -0.3)
                @test test_flux(stepper, fieldname=fieldname, top_flux=top_flux)
            end
        end
    end

    @test test_nonlocal_salinity_flux_util()
    @test test_nonlocal_temperature_flux_util()
end