Ejemplo n.º 1
0
def test_gsf_swath_summary_save_create(gsf_test_data_03_06: GsfDatafile):
    file_handle = c_int(0)

    swath_summary_id = c_gsfDataID()
    swath_summary_id.recordID = RecordType.GSF_RECORD_SWATH_BATHY_SUMMARY

    record = c_gsfRecords()
    record.summary = c_gsfSwathBathySummary(
        start_time=SUMMARY_RECORD.start_time,
        end_time=SUMMARY_RECORD.end_time,
        min_latitude=SUMMARY_RECORD.min_lat,
        max_latitude=SUMMARY_RECORD.max_lat,
        min_longitude=SUMMARY_RECORD.min_long,
        max_longitude=SUMMARY_RECORD.max_long,
        min_depth=SUMMARY_RECORD.min_depth,
        max_depth=SUMMARY_RECORD.max_depth,
    )

    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_CREATE,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_written = gsfpy.bindings.gsfWrite(file_handle,
                                            byref(swath_summary_id),
                                            byref(record))
    assert_that(bytes_written).is_equal_to(SUMMARY_RECORD_LENGTH)

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Read it back out and check that it matches expected values
    file_handle = c_int(0)
    gsf_read_data_id = c_gsfDataID()
    gsf_read_data_id.recordID = RecordType.GSF_RECORD_SWATH_BATHYMETRY_PING

    written_record = c_gsfRecords()

    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHY_SUMMARY,
        byref(gsf_read_data_id),
        byref(written_record),
    )
    assert_that(bytes_read).is_equal_to(SUMMARY_RECORD_LENGTH)

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    assert_that(SummaryRecord.from_summary(
        written_record.summary)).is_equal_to(SUMMARY_RECORD)
Ejemplo n.º 2
0
def test_gsfCopyRecords_success(gsf_test_data_03_06):
    """
    Open the test GSF file, read a record, then copy the contents to
    a new gsfRecords structure.
    """
    # Arrange
    file_handle = c_int(0)
    data_id = c_gsfDataID()
    source_records = c_gsfRecords()
    target_records = c_gsfRecords()

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_COMMENT,
        byref(data_id),
        byref(source_records),
    )
    assert_that(bytes_read).is_equal_to(156)

    return_value = gsfpy.bindings.gsfCopyRecords(
        pointer(target_records), pointer(source_records)
    )
    assert_that(return_value).is_zero()

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Assert
    with soft_assertions():
        assert_that(target_records.comment.comment_time.tv_sec).is_equal_to(
            source_records.comment.comment_time.tv_sec
        )
        assert_that(target_records.comment.comment_time.tv_nsec).is_equal_to(
            source_records.comment.comment_time.tv_nsec
        )
        assert_that(target_records.comment.comment_length).is_equal_to(
            source_records.comment.comment_length
        )
        assert_that(addressof(target_records.comment.comment)).is_not_equal_to(
            addressof(source_records.comment.comment)
        )
        assert_that(string_at(target_records.comment.comment)).is_equal_to(
            string_at(source_records.comment.comment)
        )
Ejemplo n.º 3
0
def test_gsfWrite_success(tmp_path):
    """
    Write a single comment record to a new GSF file
    """
    # Arrange
    file_handle = c_int(0)

    data_id = c_gsfDataID()
    data_id.recordID = RecordType.GSF_RECORD_COMMENT

    comment = b"My first comment"
    records = c_gsfRecords()
    records.comment.comment_time.tvsec = c_int(1000)
    records.comment.comment_length = c_int(len(comment))
    records.comment.comment = create_string_buffer(comment)

    record_size = 36  # bytes

    tmp_gsf_file_path = os.fsencode(str(tmp_path / "temp.gsf"))

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        tmp_gsf_file_path, FileMode.GSF_CREATE, byref(file_handle)
    )
    assert_that(return_value).is_zero()

    bytes_written = gsfpy.bindings.gsfWrite(file_handle, byref(data_id), byref(records))
    assert_that(bytes_written).is_equal_to(record_size)

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Read comment from newly created file to check it is as expected
    data_id = c_gsfDataID()
    data_id.recordID = RecordType.GSF_RECORD_COMMENT

    records = c_gsfRecords()

    return_value = gsfpy.bindings.gsfOpen(
        tmp_gsf_file_path, FileMode.GSF_READONLY, byref(file_handle)
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle, RecordType.GSF_RECORD_COMMENT, byref(data_id), byref(records),
    )
    assert_that(bytes_read).is_equal_to(record_size)

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    assert_that(string_at(records.comment.comment)).is_equal_to(comment)
Ejemplo n.º 4
0
def test_gsfGetSonarTextName_success(gsf_test_data_03_06):
    """
    Open the test GSF file, read a multibeam ping record, then retrieve
    the name of the sonar equipment used to capture it.
    """
    # Arrange
    file_handle = c_int(0)
    data_id = c_gsfDataID()
    records = c_gsfRecords()

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHYMETRY_PING,
        byref(data_id),
        byref(records),
    )
    assert_that(bytes_read).is_equal_to(6116)

    sonar_text_name = gsfpy.bindings.gsfGetSonarTextName(byref(records.mb_ping))

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Assert
    assert_that(sonar_text_name).is_equal_to("Kongsberg EM3002D")
Ejemplo n.º 5
0
def test_gsfPercent_success(gsf_test_data_03_06):
    """
    Open the test GSF file, read 4 records, then retrieve the location of the file
    pointer as a percentage of the total file size.
    """
    # Arrange
    file_handle = c_int(0)
    data_id = c_gsfDataID()
    records = c_gsfRecords()

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY_INDEX,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    for i in range(4):
        gsfpy.bindings.gsfRead(
            file_handle, RecordType.GSF_NEXT_RECORD, byref(data_id), byref(records)
        )

    percent = gsfpy.bindings.gsfPercent(file_handle)
    assert_that(percent).is_equal_to(4)

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()
Ejemplo n.º 6
0
def test_gsfRead_success(gsf_test_data_03_06):
    """
    Read a comment record from a GSF file.
    """
    file_handle = c_int(0)
    data_id = c_gsfDataID()
    records = c_gsfRecords()

    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle, RecordType.GSF_RECORD_COMMENT, byref(data_id), byref(records),
    )
    assert_that(bytes_read).is_equal_to(156)

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    assert_that(string_at(records.comment.comment)).is_equal_to(
        (
            b"Bathy converted from HIPS file: "
            b"M:\\CCOM_Processing\\CARIS_v9\\HIPS\\HDCS_Data\\EX1604"
            b"\\Okeanos_2016\\2016-083\\0029_20160323_185603_EX1604_MB"
        )
    )
Ejemplo n.º 7
0
def test_gsfIsStarboardPing_success(gsf_test_data_03_06):
    """
    Open the test GSF file, read a multibeam ping record, then find out if
    it is a starboard ping.
    """
    # Arrange
    file_handle = c_int(0)
    data_id = c_gsfDataID()
    records = c_gsfRecords()

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHYMETRY_PING,
        byref(data_id),
        byref(records),
    )
    assert_that(bytes_read).is_equal_to(6116)

    is_starboard_ping: int = gsfpy.bindings.gsfIsStarboardPing(byref(records))

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Assert
    assert_that(is_starboard_ping).is_false()
Ejemplo n.º 8
0
def test_gsfGetMBParams_success(gsf_test_data_03_06):
    """
    Set MB params, read a GSF record and copy fields to a gsfMBParams
    structure.
    """
    # Arrange
    mbparams_in = c_gsfMBParams()
    gsfpy.bindings.gsfInitializeMBParams(byref(mbparams_in))
    mbparams_in.horizontal_datum = c_int(57)

    mbparams_out = c_gsfMBParams()
    gsfpy.bindings.gsfInitializeMBParams(byref(mbparams_out))

    records = c_gsfRecords()
    data_id = c_gsfDataID()

    file_handle = c_int(0)
    num_arrays = c_int(1)

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    return_value = gsfpy.bindings.gsfPutMBParams(
        byref(mbparams_in), byref(records), file_handle, num_arrays
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHYMETRY_PING,
        byref(data_id),
        byref(records),
    )
    assert_that(bytes_read).is_equal_to(6116)

    return_value = gsfpy.bindings.gsfGetMBParams(
        byref(records), byref(mbparams_out), byref(num_arrays)
    )
    assert_that(return_value).is_zero()

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Assert
    with soft_assertions():
        assert_that(mbparams_out.horizontal_datum).is_equal_to(
            mbparams_in.horizontal_datum
        )
        assert_that(mbparams_out.number_of_transmitters).is_equal_to(1)
        assert_that(mbparams_out.number_of_receivers).is_equal_to(1)
Ejemplo n.º 9
0
def test_gsfGetScaleFactor_success(gsf_test_data_03_06):
    """
    Read a GSF record and get the beam array field size, compression flag,
    multiplier and DC offset applied to it.
    """
    # Arrange
    file_handle = c_int(0)
    records = c_gsfRecords()
    data_id = c_gsfDataID()
    subrecord_id = (
        ScaledSwathBathySubRecord.GSF_SWATH_BATHY_SUBRECORD_MEAN_CAL_AMPLITUDE_ARRAY
    )

    c_flag = c_ubyte()
    multiplier = c_double()
    offset = c_double()

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHYMETRY_PING,
        byref(data_id),
        byref(records),
    )
    assert_that(bytes_read).is_equal_to(6116)

    return_value = gsfpy.bindings.gsfGetScaleFactor(
        file_handle, subrecord_id, byref(c_flag), byref(multiplier), byref(offset)
    )
    assert_that(return_value).is_zero()

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Assert
    with soft_assertions():
        assert_that(c_flag.value).is_equal_to(0)
        assert_that(multiplier.value).is_equal_to(2)
        assert_that(offset.value).is_equal_to(0)
Ejemplo n.º 10
0
def test_gsfSetDefaultScaleFactor_success(gsf_test_data_03_06):
    """
    Set estimated scale factors for a gsfSwathBathyPing structure.
    """
    # Arrange
    file_handle = c_int(0)
    records = c_gsfRecords()
    data_id = c_gsfDataID()

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHYMETRY_PING,
        byref(data_id),
        byref(records),
    )
    assert_that(bytes_read).is_equal_to(6116)

    # Set multibeam ping scale factors to be empty
    records.mb_ping.scaleFactors = c_gsfScaleFactors()

    return_value = gsfpy.bindings.gsfSetDefaultScaleFactor(byref(records.mb_ping))
    assert_that(return_value).is_zero()

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Assert
    with soft_assertions():
        index = 2
        assert_that(
            records.mb_ping.scaleFactors.scaleTable[index].compressionFlag
        ).is_equal_to(0x00)
        assert_that(
            records.mb_ping.scaleFactors.scaleTable[index].multiplier
        ).is_equal_to(25)
        assert_that(records.mb_ping.scaleFactors.scaleTable[index].offset).is_equal_to(
            0
        )
Ejemplo n.º 11
0
def test_gsfGetSwathBathyArrayMinMax_success(gsf_test_data_03_06):
    """
    Open the test GSF file, read a multibeam ping record, then get min and
    max supportable values for the swath bathymetry arrays in the given ping.
    """
    # Arrange
    file_handle = c_int(0)
    data_id = c_gsfDataID()
    records = c_gsfRecords()
    min_value = c_double()
    max_value = c_double()
    subrecord_id = c_int(1)

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHYMETRY_PING,
        byref(data_id),
        byref(records),
    )
    assert_that(bytes_read).is_equal_to(6116)

    return_value = gsfpy.bindings.gsfGetSwathBathyArrayMinMax(
        byref(records.mb_ping), subrecord_id, byref(min_value), byref(max_value),
    )
    assert_that(return_value).is_zero()

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Assert
    with soft_assertions():
        assert_that(min_value.value).is_equal_to(3562.32)
        assert_that(max_value.value).is_equal_to(4217.67)
Ejemplo n.º 12
0
def test_gsfGetSwathBathyBeamWidths_success(gsf_test_data_03_06):
    """
    Open the test GSF file, read a multibeam ping record, then get fore-aft and
    port-starboard beam widths, in degrees, for the given ping.
    """
    # Arrange
    file_handle = c_int(0)
    data_id = c_gsfDataID()
    records = c_gsfRecords()
    fore_aft = c_double()
    athwartship = c_double()

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHYMETRY_PING,
        byref(data_id),
        byref(records),
    )
    assert_that(bytes_read).is_equal_to(6116)

    return_value = gsfpy.bindings.gsfGetSwathBathyBeamWidths(
        byref(records), byref(fore_aft), byref(athwartship),
    )
    assert_that(return_value).is_zero()

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Assert
    with soft_assertions():
        assert_that(fore_aft.value).is_equal_to(1.5)
        assert_that(athwartship.value).is_equal_to(1.5)
Ejemplo n.º 13
0
def test_gsf_swath_summary(gsf_test_data_03_06: GsfDatafile):
    file_handle = c_int(0)

    swath_summary_id = c_gsfDataID()
    swath_summary_id.recordID = RecordType.GSF_RECORD_SWATH_BATHY_SUMMARY

    records = c_gsfRecords()

    # Read from file
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHY_SUMMARY,
        byref(swath_summary_id),
        byref(records),
    )
    assert_that(bytes_read).is_equal_to(SUMMARY_RECORD_LENGTH)

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    assert_that(SummaryRecord.from_summary(records.summary)).is_equal_to(
        SummaryRecord(
            min_lat=8.7118203,
            max_lat=8.713543,
            min_long=167.4759106,
            max_long=167.477003,
            min_depth=3862.43,
            max_depth=4145.0,
            start_time_sec=1458759363,
            start_time_nsec=224999904,
            end_time_sec=1458759436,
            end_time_nsec=727999925,
        ))
Ejemplo n.º 14
0
def test_gsfFileIsNewSurveyLine_success(gsf_test_data_03_06):
    """
    Open the test GSF file, read a ping, then discover whether it comes
    from a new survey line.
    """
    # Arrange
    file_handle = c_int(0)
    data_id = c_gsfDataID()
    records = c_gsfRecords()
    azimuth_change = c_double(90)
    last_heading = c_double(180)

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHYMETRY_PING,
        byref(data_id),
        byref(records),
    )
    assert_that(bytes_read).is_equal_to(6116)

    is_new_survey_line: int = gsfpy.bindings.gsfIsNewSurveyLine(
        file_handle, byref(records), azimuth_change, byref(last_heading)
    )

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Assert
    assert_that(is_new_survey_line).is_true()
Ejemplo n.º 15
0
    def read(
        self,
        desired_record: RecordType = RecordType.GSF_NEXT_RECORD,
        record_number: int = 0,
    ) -> Tuple[c_gsfDataID, c_gsfRecords]:
        """
        When the file is open in GSF_READONLY_INDEX or GSF_UPDATE_INDEX mode then the
        record_number parameter may be used to indicate which instance of the record to
        read.
        :param desired_record: Record type to read
        :param record_number: nth occurrence of the record to read from, starting from 1
        :return: Tuple of c_gsfDataID and c_gsfRecords
        :raises GsfException: Raised if anything went wrong
        """
        data_id = c_gsfDataID()
        data_id.record_number = record_number

        records = c_gsfRecords()

        _handle_failure(
            gsfRead(self._handle, desired_record, byref(data_id), byref(records))
        )

        return data_id, records
Ejemplo n.º 16
0
def test_gsfPutMBParams_success(gsf_test_data_03_06):
    """
    Create a gsfMBParams structure and copy fields to a gsfRecords
    structure.
    """
    # Arrange
    mbparams = c_gsfMBParams()
    gsfpy.bindings.gsfInitializeMBParams(byref(mbparams))

    # Only WGS-84 (57) and NAD-83 (38) horizontal datum values are
    # supported by GSF - see gsf.h
    mbparams.horizontal_datum = c_int(57)
    # Set number_of_transmitters and number_of_receivers to zero
    # so that num_arrays param is used for these values when
    # setting the params in the gsfRecords structure.
    mbparams.number_of_transmitters = c_int(0)
    mbparams.number_of_receivers = c_int(0)
    mbparams.to_apply.position_x_offset = c_double(1.1)
    mbparams.to_apply.position_y_offset = c_double(2.2)
    mbparams.to_apply.position_z_offset = c_double(3.3)
    mbparams.applied.position_x_offset = c_double(4.4)
    mbparams.applied.position_y_offset = c_double(5.5)
    mbparams.applied.position_z_offset = c_double(6.6)

    records = c_gsfRecords()
    # data_id = c_gsfDataID()

    file_handle = c_int(0)
    num_arrays = c_int(1)

    # Act
    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    return_value = gsfpy.bindings.gsfPutMBParams(
        byref(mbparams), byref(records), file_handle, num_arrays
    )
    assert_that(return_value).is_zero()

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Assert
    with soft_assertions():
        assert_that(records.process_parameters.number_parameters).is_equal_to(63)
        # param zero is always epoch start time
        assert_that(string_at(records.process_parameters.param[0])).is_equal_to(
            b"REFERENCE TIME=1970/001 00:00:00"
        )
        # params 7 (NUMBER_OF_RECEIVERS) & 8 (NUMBER_OF_TRANSMITTERS) should have
        # a value equal to num_arrays
        assert_that(string_at(records.process_parameters.param[7])).is_equal_to(
            b"NUMBER_OF_RECEIVERS=1"
        )
        assert_that(string_at(records.process_parameters.param[8])).is_equal_to(
            b"NUMBER_OF_TRANSMITTERS=1"
        )
        # param 9 (DEPTH_CALCULATION) should have a value of 'UNKNOWN' as it
        # has not been updated since being initialized
        assert_that(string_at(records.process_parameters.param[9])).is_equal_to(
            b"DEPTH_CALCULATION=UNKNOWN"
        )
        # param 19 (POSITION_OFFSET_TO_APPLY) should have values x,y,z equal to
        # corresponding values in mbparams.to_apply
        assert_that(string_at(records.process_parameters.param[19])).is_equal_to(
            b"POSITION_OFFSET_TO_APPLY=+01.10,+02.20,+03.30"
        )
        # param 42 (APPLIED_POSITION_OFFSET) should have values x,y,z equal to
        # corresponding values in mbparams.to_apply
        assert_that(string_at(records.process_parameters.param[42])).is_equal_to(
            b"APPLIED_POSITION_OFFSET=+04.40,+05.50,+06.60"
        )
        # param 61 (GEOID) should have a value equal to WGS-84, corresponding to
        # mbparams.horizontal_datum value of 57
        assert_that(string_at(records.process_parameters.param[61])).is_equal_to(
            b"GEOID=WGS-84"
        )
Ejemplo n.º 17
0
def _new_comment(comment: bytes) -> c_gsfRecords:
    record = c_gsfRecords()
    record.comment.comment_time.tvsec = c_int(1000)
    record.comment.comment_length = c_int(len(comment))
    record.comment.comment = create_string_buffer(comment)
    return record
Ejemplo n.º 18
0
def test_gsf_swath_summary_save_update(gsf_test_data_03_06: GsfDatafile):
    file_handle = c_int(0)

    swath_summary_data_id = c_gsfDataID()
    swath_summary_data_id.recordID = RecordType.GSF_RECORD_SWATH_BATHY_SUMMARY

    record = c_gsfRecords()

    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_UPDATE,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHY_SUMMARY,
        byref(swath_summary_data_id),
        byref(record),
    )
    assert_that(bytes_read).is_equal_to(SUMMARY_RECORD_LENGTH)

    assert_that(SummaryRecord.from_summary(
        record.summary)).is_not_equal_to(SUMMARY_RECORD)

    # copy our data into the record
    SUMMARY_RECORD.to_summary(record.summary)

    # Go back to the first record so it doesn't write
    # the updated first summary over the top of the second one
    return_value = gsfpy.bindings.gsfSeek(file_handle,
                                          SeekOption.GSF_PREVIOUS_RECORD)
    assert_that(return_value).is_zero()

    bytes_written = gsfpy.bindings.gsfWrite(file_handle,
                                            byref(swath_summary_data_id),
                                            byref(record))
    assert_that(bytes_written).is_equal_to(SUMMARY_RECORD_LENGTH)

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    # Read it back out and check it was saved correctly

    file_handle = c_int(0)
    updated_swath_summary_data_id = c_gsfDataID()
    updated_swath_summary_data_id.recordID = RecordType.GSF_RECORD_SWATH_BATHY_SUMMARY

    updated_record = c_gsfRecords()

    return_value = gsfpy.bindings.gsfOpen(
        os.fsencode(str(gsf_test_data_03_06.path)),
        FileMode.GSF_READONLY,
        byref(file_handle),
    )
    assert_that(return_value).is_zero()

    bytes_read = gsfpy.bindings.gsfRead(
        file_handle,
        RecordType.GSF_RECORD_SWATH_BATHY_SUMMARY,
        byref(updated_swath_summary_data_id),
        byref(updated_record),
    )
    assert_that(bytes_read).is_equal_to(SUMMARY_RECORD_LENGTH)

    return_value = gsfpy.bindings.gsfClose(file_handle)
    assert_that(return_value).is_zero()

    assert_that(SummaryRecord.from_summary(
        updated_record.summary)).is_equal_to(SUMMARY_RECORD)