comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » reading unformatted data into a structure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
reading unformatted data into a structure [message #29751] Mon, 18 March 2002 17:40
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
I have an unformatted data file which I am trying to read and I am having
only limited success. The data file was created on a Sun machine and it is
being read on a win32 machine (I have set the swap_if_little_endian keyword
on the open statement). As for the file format, all I have to go on is the
C header file that describes the records in the file.

Early on in the header I find this:

// Variable types:
// int is 32 bit integer.
// short is 16 bit integer.


Here are the first few lines of the header (all of the data types found in
the header are in these lines):

typedef struct
{
int fileFormatVersion; /* The file format version number. */
int points; /* Number of xyz points on the file. */
int time; /* UNIX time of file generation,
seconds since 1/1 1970. */
unsigned short coordSys; /* The coordinate system used:
0 = Geographical lat/long.
1 = Projection */
char projection[32]; /* Projection name (see above) */
int projParam1; /* 1. projection parameter (see above). */
int projParam2; /* 2. projection parameter (see above). */
int projParam3; /* 3. projection parameter (see above). */
int projParam4; /* 4. projection parameter (see above). */
int projParam5; /* 5. projection parameter (see above). */
char datum[32]; /* Name of the datum (see above). */
char ellLargeHalfAxis[16]; /* Large half axis of the ellipsoide. */
....


From the comments about variable types and the structure definition I
created an IDL structure that I think matches the C struct (again, I'll list
the first few lines):

header = { fileFormatVersion:0L, $
points:0L, $
time:0L, $
coordSys:0, $
projection:bytarr(32), $
projParam1:0L, $
projParam2:0L, $
projParam3:0L, $
projParam4:0L, $
projParam5:0L, $
datum:bytarr(32), $
ellLargeHalfAxis:bytarr(16), $
....


I open the data file and read the header like so:

openr, lun, 'J:\hydrographic\1.xyz', /get_lun, $
/swap_if_little_endian
readu, lun, header



Am I doing this correctly? I know I am close because I get what seems like
a valid time and I know I get a valid datum. But my data doesn't seem
right. I just want to check that I am using the correct types in my IDL
struct and that I am reading in the data correctly.


Also, I know I have seen this but how do I convert the decimal ASCII chars
in my bytarr's to a string?


Thanks.


-Rick
[Message index]
 
Read Message
Previous Topic: Re: Speedup in Object Graphics
Next Topic: HDF->DXF

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 12:53:11 PDT 2025

Total time taken to generate the page: 0.48014 seconds