Skip to content

add support for big-endian nvt2 grid file #345

Closed
@bastik

Description

There are binary ntv2 grid files in little-endian and in big-endian. Currently, proj.4 assumes all files are little-endian and fails otherwise.

The code to switch the endianness of the binary data is already there. But the trigger, when to switch, can be improved to match that of the nvt2 data.

The type of the ntv2 file can be detected from the first 16 bytes:

$ xxd -l 16 ntf_r93.gsb  # little endian
0000000: 4e55 4d5f 4f52 4543 0b00 0000 0000 0000  NUM_OREC........
$ xxd -l 16 ntf_r93_b.gsb  # big endian
0000000: 4e55 4d5f 4f52 4543 0000 000b 0000 0000  NUM_OREC........

The number of overview header records is always 11, which is also hardcoded in pj_gridinfo_init_ntv2. Therefore one can check if byte 9 to 12 equals the integer 11 encoded in LE or BE.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions