[Proj] Proj binary input and output

pw p.willis at telus.net
Fri Aug 19 14:55:37 PDT 2005


Gerald I. Evenden wrote:
> In your example the input should be a (double)longitude followed by a 
> (double)
> latitude (both in local binary).
> 
> An example I often use in checking projections is where the data is passed
> by binary through a pipe:
> 
> proj +proj=test [+other_opts] -o | proj +proj=test [+other_opts] -I -i
> 
> where the sysin input to the first program is ASCII, the output piped to 
> the second is
> binary and input to the second which sysout's ASCII.
> 
> Note that proj uses
> 
> fread(&data, sizeof(UV), 1, fid)
> 
> for binary input and equivalent fwrite for binary output where
> 
> typedef struct { double u, v; } UV;
> 
> Unless order flipping options are used, u=longitude and v=latitude.
> 
> On Fri, 2005-08-19 at 10:39 -0700, pw wrote:
> 


My test file is a double precision binary file with 
lonlatlonlat...(113000 times)

/*binary file -> [proj] -> binary -> [invproj] -> text*/

proj +proj=utm +zone=17 +ellps=WGS84 -b binary_file.bin |  \
proj -I -i +proj=utm +zone=17 +ellps=WGS84

OR:

/*binary to text*/
proj +proj=utm +zone=17 +ellps=WGS84 -i binary_file.bin

Both of these give me poor output under MS Windows.
I haven't tried this under linux yet. That would tell me
if the problem is with my VC 5 build under MS windows, although
the default struct alignment/packing is 8 bytes which should
be totally copacetic with the struct UV anyway since doubles are
8 bytes.

I was curious as to whether binary files were currently
supported (tested?) since this is treated in only a passing
manner in the docs.

If my command line is correct above, then my build must be wrong.
I will check my linux build to see if it responds in the same
manner.

Thanks for your help,

Peter Willis




More information about the Proj mailing list