android/spatialiteandroidlibrary/src/main/jni/geos-3.2.2/capi/geos_ts_c.cpp
unsigned char *
GEOSGeomToHEX_buf_r(GEOSContextHandle_t extHandle, const Geometry *g, size_t *size)
{
    if ( 0 == extHandle )
    {
        return NULL;
    }

    GEOSContextHandleInternal_t *handle = 0;
    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
    if ( 0 == handle->initialized )
    {
        return NULL;
    }

    using geos::io::WKBWriter;
    try
    {
        int byteOrder = static_cast<int>(handle->WKBByteOrder);
        WKBWriter w(handle->WKBOutputDims, byteOrder);
        std::ostringstream os(std::ios_base::binary);
        w.writeHEX(*g, os);
        std::string hexstring(os.str());

        char *result = gstrdup(hexstring);
        if (0 != result)
        {
            *size = hexstring.length();
        }

        return reinterpret_cast<unsigned char*>(result);
    }
    catch (const std::exception &e)
    {
        handle->ERROR_MESSAGE("%s", e.what());
    }
    catch (...)
    {
        handle->ERROR_MESSAGE("Unknown exception thrown");
    }
    
    return NULL;
}
/* Read/write wkb hex values.  Returned geometries are
   owned by the caller.*/
Read/write wkb hex values.  Returned geometries are
owned by the caller.
Read / write wkb hex values . Returned geometries are owned by the caller .
unsigned char *
GEOSGeomToHEX_buf_r(GEOSContextHandle_t extHandle, const Geometry *g, size_t *size)
{
    if ( 0 == extHandle )
    {
        return NULL;
    }
    GEOSContextHandleInternal_t *handle = 0;
    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
    if ( 0 == handle->initialized )
    {
        return NULL;
    }
    using geos::io::WKBWriter;
    try
    {
        int byteOrder = static_cast<int>(handle->WKBByteOrder);
        WKBWriter w(handle->WKBOutputDims, byteOrder);
        std::ostringstream os(std::ios_base::binary);
        w.writeHEX(*g, os);
        std::string hexstring(os.str());
        char *result = gstrdup(hexstring);
        if (0 != result)
        {
            *size = hexstring.length();
        }
        return reinterpret_cast<unsigned char*>(result);
    }
    catch (const std::exception &e)
    {
        handle->ERROR_MESSAGE("%s", e.what());
    }
    catch (...)
    {
        handle->ERROR_MESSAGE("Unknown exception thrown");
    }
    return NULL;
}
unsigned char * GEOSGeomToHEX_buf_r ( GEOSContextHandle_t extHandle , const Geometry * g , size_t * size ) { if ( 0 == extHandle ) { return NULL ; } GEOSContextHandleInternal_t * handle = 0 ; handle = reinterpret_cast < GEOSContextHandleInternal_t * > ( extHandle ) ; if ( 0 == handle -> initialized ) { return NULL ; } using geos :: io :: WKBWriter ; try { int byteOrder = static_cast < int > ( handle -> WKBByteOrder ) ; WKBWriter w ( handle -> WKBOutputDims , byteOrder ) ; std :: ostringstream os ( std :: ios_base :: binary ) ; w . writeHEX ( * g , os ) ; std :: string hexstring ( os . str ( ) ) ; char * result = gstrdup ( hexstring ) ; if ( 0 != result ) { * size = hexstring . length ( ) ; } return reinterpret_cast < unsigned char * > ( result ) ; } catch ( const std :: exception & e ) { handle -> ERROR_MESSAGE ( " " , e . what ( ) ) ; } catch ( ... ) { handle -> ERROR_MESSAGE ( " " ) ; } return NULL ; }
Read/write wkb hex values.
Read / write wkb hex values .