[Proj] How to Reengineering the cs2cs tool

Christopher Barker Chris.Barker at noaa.gov
Fri Jun 5 18:50:39 EST 2009


Glynn Clements wrote:
> 1. Write the input coordinates to a file, then run cs2cs with its
> stdin associated with that file, and read its output from your
> program.
> 
> 2. Run cs2cs with its stdout associated with a new file, feed it input
> from your program, and read the output coordinates from that file once
> cs2cs completes.
> 
> 3. Use multiple threads, with one thread feeding input to cs2cs and
> another reading the output.
> 
> 4. Use non-blocking I/O on the output, so that the program can
> continously feed input to cs2cs and read output when it's available
> without blocking when it isn't.
> 
> 5. Modify cs2cs to either call setvbuf(stdout, buf, _IOLBF, bufsize)
> at startup, or call fflush(stdout) after each line has been written.

you seem to have left out what seems to me the most obvious and natural 
way to call cs2cs from a scripting language:

much like (1) except use pipes instead of files -- why bother with the 
disk IO? You'd just need to build up a decent sized list of points to 
convert before making each call -- probably all the ones you need at the 
time.


But the best option if you are concerned about performance is to use the 
PROJ lib though language bindings. I know there are a number of Python 
options, I'm sure there are PHP or PERL ones (or use Python for your web 
app -- it's a excellent choice)

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Proj mailing list