omg_hypack
Overview & Purpose
omg_hypack parses ASCII HYPACK HYSWEEP (HSX) survey files for conversion into the Ocean Mapping Group (OMG) HDCS format. HYPACK HSX files consist of an ASCII header section terminated by an EOH (End of Header) tag, followed by line-oriented data records prefixed by 3-character record identifiers. omg_hypack validates the file signature (FTP and HSX records), parses device configurations, lever arms, multibeam/sidescan capabilities, survey parameters, and sound velocity profiles from the header, and provides a line-by-line record reader backed by OMG_Buffer.
Key Data Structures, Constants & Macros
Constants
HSX_MAX_NUM_DEVICES(100): Maximum number of configured survey devices stored inHypack_HSX_Header.HSX_MAX_NUM_SVP_LAYERS(1000): Maximum number of sound velocity profile depth layers.
Data Structures
Hypack_HSX_Device: Aggregates device metadata across multiple header record types:- From
DEV:char *name,unsigned short capability1(bitmask for position, depth, heading, MRU, extended capabilities). - From
DV2:unsigned short capability2(bitmask for multibeam, multiple transducer, GPS, sidescan, single-beam, gyro, MRU),on_tow_fish,enabled. - From
OF2:OMG_HDCS_motion_sensor offsets(Xloc,Yloc,Zloc,dHeading,dRoll,dPitch, and latencydTime). - From
SSI: Sidescan configuration (sidescan_sonar_flags,number_port_samples,number_stbd_samples). - From
MBI: Multibeam configuration (multibeam_sonar_type,multibeam_sonar_flags, hex-encoded bitmaskmultibeam_beam_data,number_beams,number_beams2,first_angle,angle_increment).
- From
Hypack_HSX_Sound_Velocity_Layer: Represents a singleSVClayer (begin_depth,end_depth,sound_velocity).Hypack_HSX_Header: Complete survey header state containing:format_version(fromHSXline)- Survey start date/time (
year,month,day,hour,minute,second) and Unix epochbasetime(computed viastdtime_from_jul_dayfrom theTNDrecord) INFfields:initial_tide_correction,initial_draft_correction,sound_velocityHSPHYSWEEP parameters:minimum_depth,maximum_depth,maximum_port_offset,maximum_stbd_offset,maximum_port_angle,maximum_stbd_angle,high_beam_quality,low_beam_quality,sonar_range,towfish_layback,work_units,dunno_HSP_12PRIprimary navigation system index (primary_navigation_system)devices[HSX_MAX_NUM_DEVICES]andnumber_of_devicessvp[HSX_MAX_NUM_SVP_LAYERS]andnumber_svp_samples
Hypack_HSX_Record: Holds a single line-oriented HSX data record:char id[4]: Null-terminated 3-character record identifier (e.g.,RMB,POS,GYR,HCP).OMG_Buffer buffer: Dynamically sized line buffer holding the raw ASCII record.
Public Functions & Signatures
int init_HSX_header(Hypack_HSX_Header *header)- Zero-initializes the
Hypack_HSX_Headerstructure.
- Zero-initializes the
int read_HSX_header(FILE *infile, Hypack_HSX_Header *header)- Rewinds
infileto byte 0, verifies the mandatoryFTP(line 1) andHSX(line 2) signatures, and loops over header lines usinggetc_line_vlengthuntilEOHis encountered. ParsesTND,INF(skipping 4 double-quoted text strings before reading tide, draft, and sound speed),PRI,HSP,DEV,DV2,OF2,MBI,SSI, andSVCrecords while ignoring planned line records (LNN,LIN,VER,PTS,LBP,EOL).
- Rewinds
int print_HSX_header(Hypack_HSX_Header *header)- Prints a formatted diagnostic summary of the parsed HSX header, decoding all device capability bitmasks (
capability1,capability2), multibeam flags (roll/pitch/heading compensation, single/dual head, depth resolution), and available beam data bitfields (0x0001range through0x2000sounding-flags).
- Prints a formatted diagnostic summary of the parsed HSX header, decoding all device capability bitmasks (
int init_HSX_Record(Hypack_HSX_Record *record)/int init_HSX_record(Hypack_HSX_Record *record)- Zeroes the record struct and initializes its internal
OMG_Buffer. (Note: defined asinit_HSX_recordinomg_hypack.cand declared asinit_HSX_Recordinomg_hypack.h.)
- Zeroes the record struct and initializes its internal
int read_HSX_Record(FILE *infile, Hypack_HSX_Record *record)/int read_HSX_record(FILE *infile, Hypack_HSX_Record *record)- Reads the next variable-length ASCII line from
infileintorecord->bufferand copies the 3-character tag intorecord->id. Returns1on EOF,0on success.
- Reads the next variable-length ASCII line from
int free_HSX_Record(Hypack_HSX_Record *record)- Frees the internal
OMG_Bufferand resets the record structure.
- Frees the internal
How It Fits Into the OMG Architecture
omg_hypack is the parsing engine behind hypack2omg (code/hypack/hypack2omg.c), which converts HYPACK HYSWEEP .HSX files into OMG HDCS bathymetry, navigation, and attitude files. It relies on omg_buffer (getc_line_vlength) for safe arbitrary-length line reading, stdtime for Julian day and epoch time conversion, and OMG_HDCS_motion_sensor from OMG_HDCS_jversion.h to store sensor lever arms and mounting angles directly in OMG conventions.