0

From what I learned, when using GEOS in C/C++, it should be initialized first using initGEOS :

extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function,
         GEOSMessageHandler error_function);

, which takes two error handling functions notice_function, error_function.

My question is:

How can these two handler functions be accessed and called in C? (e.g. when one wants to print some notice messages while debugging an existing GEOS function)

I can't seem to find the documentation about this.

0

It seems to be GEOSContextHandle_HS::ERROR_MESSAGE(fmt, ...). An example of calling the notice/error functions seems to be in the source code, e.g. for GEOSWKTWriter_destroy:

 void
 GEOSWKTWriter_destroy(WKTWriter *Writer)
 {
      GEOSWKTWriter_destroy_r( handle, Writer );
 }

in which handle is a global variable.

GEOSContextHandle_t handle

Then, this handle is used to call ERROR_MESSAGE e.g.:

char* GEOSWKTWriter_write_r(GEOSContextHandle_t  extHandle,
... )   
{
    //...
    GEOSContextHandleInternal_t *handle = 0;
    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
    if ( 0 == handle->initialized )
    {
    return NULL;
    }

    try
    {
       //...
    }
    catch (const std::exception &e)
    {
    handle->ERROR_MESSAGE("%s", e.what());
    }
    //...
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.