[PROJ] PROJ without proj.db

Kristian Evers kristianevers at gmail.com
Wed Mar 10 00:14:34 PST 2021


Here’s the source proj_log_func():

/*****************************************************************************/
void proj_log_func (PJ_CONTEXT *ctx, void *app_data, PJ_LOG_FUNCTION logf) {
/******************************************************************************
Put a new logging function into P's context. The opaque object app_data is
passed as first arg at each call to the logger
******************************************************************************/
    if (nullptr==ctx)
        ctx = pj_get_default_ctx ();
    ctx->logger_app_data = app_data;
    if (nullptr!=logf)
       ctx->logger = logf;
}

So, by putting nullptr as the log function you end up with the default logging
function. Try setting up an actual logger function and pass a pointer to that.

I can see how you might think that a null pointer would achieve something else,
though. The docs should clarify that or perhaps the functionality should be
changed to let logf==nullptr explicitly mean “shut up”. The latter is likely the
best move based on the fact that if you are happy with the default logger you
probably wouldn’t call proj_log_func() in the first place.

/Kristian

> On 10 Mar 2021, at 08:37, Søren Holm <sgh at sgh.dk> wrote:
> 
> I get this in stderr
> 
> pj_obj_create: Cannot find proj.db
> 
> Neither proj_log_level or proj_log_func makes any difference.
> 
> My code basically looks like this :
> 
> ctx = proj_context_create();
> proj_log_level(ctx, PJ_LOG_NONE);
> proj_log_func(ctx, nullptr, logger);
> proj = proj_create(ctx, def);
> 
> But still proj_create(ctx, def) gives me that output. It is clear to me that 
> for some reason loglevel and/or logfunction is overwritten  during 
> proj_create. I that seems like unwanted behavior.
> 
> tirsdag den 9. marts 2021 22.05.33 CET skrev Kristian Evers:
>> In what way is PROJ complaining? That is not clear to me from the setup you
>> describe.
> 
>> /Kristian
>> 
>> 
>>> On 9 Mar 2021, at 19:59, Søren Holm <sgh at sgh.dk> wrote:
>>> 
>>> Sure
>>> 
>>> To elaborate a bit.
>>> 
>>> My application in running on Android. That implies a couple of things.
>>> 
>>> 1. It is difficult to distribute static files - they are always placed in
>>> a 
> compressed file and regular linux file io functions (that sqlite
>>> uses) does not work on those.
>>> 
>>> 2. Given that I do not need the database, increasing my apk-size by 8MB is
>>> 
> unnecessary.
>>> 
>>> So - I just need a way to have PROJ stop complaining about a database that
>>> - 
> for my usecase - is not needed to resolved the initstring.
>>> 
>>> In all of this my assumption is that proj.db *MUST* be the file generated
>>> for a 
> specific PROJ-version. Please correct me if I'm wrong about that
>>> :) 
>>> tirsdag den 9. marts 2021 19.42.49 CET skrev Kristian Evers:
>>> 
>>>>> What is the best way to avoid PROJ constantly
>>>>> complaining about proj.db being missing ?
>>>> 
>>>> 
>>>> By putting proj.db in $PROJ_LIB.
>>>> 
>>>> /Kristian
>>> 
>>> 
>>> 
>>> -- 
>>> Søren Holm
>>> 
>>> 
>>> _______________________________________________
>>> PROJ mailing list
>>> PROJ at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/proj
>> 
>> 
> 
> 
> -- 
> Søren Holm
> 
> 
> _______________________________________________
> PROJ mailing list
> PROJ at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/proj



More information about the PROJ mailing list