[Proj] libproj4 thread safety

Gerald Evenden gerald.evenden at verizon.net
Wed Feb 23 13:14:26 EST 2005

Before these emails get tooo long and complicated, let me suggest the 

pj_init return a pointer if an error free initialization of a 
projections occurs otherwise
a null value when an error occurs and the pj_errno global may be 
checked for
the reason for failure.  THIS IS THE ONLY place pj_errno will be 
Any subsequent call to pj_init will immediately reset pj_errno prior to 
the request.

The return structure may be modified by pj_fwd or pj_inv but pj_errno 
will not
be affected by any calls to these routines.

Errors in the calls to pj_fwd and pj_inv will be indicated by HUGE 
values in
both elements of the return structure.  Each call to pj_fwd/pj_inv will 
reset of any error flags associated with the argument projection 
a the beginning of processing the request.

A call to int pj_error(void *pj) will return the error status of the 
structure pj
which reflects the last pj_fwd/pj_inv call with THAT pj structure.  A 
negative number indicates an
error occurred.  To get description follow current procedures with 

The error code status in the pj structure is the only thing that is 
likely to change.
I do not consider pj as const inside the library.

With simple minded usage---like my own---this will not cause any changes
in application code that does not do cartwheels over error codes.  
I only check for HUGE and don't give a s__t why. ;-)

I think that may solve the problem without major usage changes.  The 
area that may be a hassle is during initialization.

Lastly, overhead with multiple pj structs should not me considered a 
Not much memory is involved and there is no issue with speed.  I DO NOT
recommend that copies be made of pj as there may be links to other
sections of allocated memory and order of freeing pj's could be wooley.

Would this specification fill the bill?
Jerry and the low riders: Daisy Mae and Joshua.
"The whole religious complexion of the modern world is due to the
absence from Jerusalem of a lunatic asylum." Havelock Ellis, 1914

More information about the Proj mailing list