Opened 17 years ago

Last modified 17 years ago

#1933 closed enhancement

GeoTIFF GTIFMemBufFromWkt data is platform dependent but should always be MSB ordered — at Version 2

Reported by: castalia Owned by: warmerdam
Priority: high Milestone:
Component: default Version: 1.4.2
Severity: major Keywords: GeoTIFF "data order"
Cc:

Description (last modified by warmerdam)

GeoTIFF binary data should be MSB (high-endian) ordered. However, the GTIFMemBufFromWkt function (found in frmts/gtiff/gt_wkt_srs.cpp) which generates the GeoTIFF data - using TIFFSetField, GTIFSetFromOGISDefn and GTIFWriteKeys functions - produces LSB ordered binary data on LSB (little-endian) platforms. Since the contents of the data buffer returned by GTIFMemBufFromWkt are opaque to the user of the function, it, or its dependencies, should detect the platform data order and ensure that MSB ordered binary data is always returned. Note the the function user can not reliably reorder the data since what is returned is a mix of text and binary data.

The sample data (non-printable byte values printed in hex format) generated by GTIFMemBufFromWkt, below, from the same source demonstrates the problem.

MSB platform (Darwin.PowerPC):

GeoTIFF data, 499 bytes -
MM 0x00 * 0x00 0x00 0x00 0x0a 0x00 0x00 0x00 0x0f 0x01 0x00 0x00 0x03
0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x00 0x01 0x01 0x00 0x03 0x00 0x00
0x00 0x01 0x00 0x01 0x00 0x00 0x01 0x02 0x00 0x03 0x00 0x00 0x00 0x01
0x00 0x08 0x00 0x00 0x01 0x03 0x00 0x03 0x00 0x00 0x00 0x01 0x00 0x01
0x00 0x00 0x01 0x06 0x00 0x03 0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x00
0x01 0x11 0x00 0x04 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x08 0x01 0x15
0x00 0x03 0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x00 0x01 0x16 0x00 0x03
0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x00 0x01 0x17 0x00 0x04 0x00 0x00
0x00 0x01 0x00 0x00 0x00 0x01 0x01 0x1c 0x00 0x03 0x00 0x00 0x00 0x01
0x00 0x01 0x00 0x00 0x83 0x0e 0x00 0x0c 0x00 0x00 0x00 0x03 0x00 0x00
0x00 0xc4 0x84 0x82 0x00 0x0c 0x00 0x00 0x00 0x06 0x00 0x00 0x00 0xdc
0x87 0xaf 0x00 0x03 0x00 0x00 0x00 L 0x00 0x00 0x01 0x0c 0x87 0xb0 0x00
0x0c 0x00 0x00 0x00 0x06 0x00 0x00 0x01 0xa4 0x87 0xb1 0x00 0x02 0x00
0x00 0x00 0x1f 0x00 0x00 0x01 0xd4 0x00 0x00 0x00 0x00 ? 0xd0 0x00 0x00
0x00 0x00 0x00 0x00 ? 0xd0 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0xc0 0x85 'M 0xf3 0xb6 E 0xa2 0xc1 0x14 0x89 &' 0xcc : 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x00 0x00
0x12 0x04 0x00 0x00 0x00 0x00 0x01 0x00 0x01 0x04 0x01 0x00 0x00 0x00
0x01 0x00 0x01 0x04 0x02 0x87 0xb1 0x00 0x15 0x00 0x00 0x08 0x00 0x00
0x00 0x00 0x01 0x7f 0xff 0x08 0x01 0x87 0xb1 0x00 0x09 0x00 0x15 0x08
0x02 0x00 0x00 0x00 0x01 0x7f 0xff 0x08 0x06 0x00 0x00 0x00 0x01 # 0x8e
0x08 0x08 0x00 0x00 0x00 0x01 0x7f 0xff 0x08 0x09 0x87 0xb0 0x00 0x01
0x00 0x04 0x08 0x0a 0x87 0xb0 0x00 0x01 0x00 0x05 0x0c 0x00 0x00 0x00
0x00 0x01 0x7f 0xff 0x0c 0x02 0x00 0x00 0x00 0x01 0x7f 0xff 0x0c 0x03
0x00 0x00 0x00 0x01 0x00 0x11 0x0c 0x04 0x00 0x00 0x00 0x01 #) 0x0c
0x0a 0x87 0xb0 0x00 0x01 0x00 0x02 0x0c 0x0b 0x87 0xb0 0x00 0x01 0x00
0x03 0x0c 0x10 0x87 0xb0 0x00 0x01 0x00 0x01 0x0c 0x11 0x87 0xb0 0x00
0x01 0x00 0x00 0xc0 0x14 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 R 0xdb C
0x95 0x81 0x06 % 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 AI 0xe8 0xe2 h 0x10 bNAI 0xe8 0xe2 h 0x10
bNEquirectangular MARS|GCS_MARS| 0x00

LSB platform (Linux.X86_64):

GeoTIFF data, 499 bytes -
MM* 0x00 0x0a 0x00 0x00 0x00 0x00  0x0f 0x00 0x00 0x01 0x03 0x00 0x01
0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x01 0x01 0x03 0x00 0x01 0x00 0x00
0x00 0x00 0x00 0x01 0x00 0x02 0x01 0x03 0x00 0x01 0x00 0x00 0x00 0x00
0x00 0x08 0x00 0x03 0x01 0x03 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x01
0x00 0x06 0x01 0x03 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x11
0x01 0x04 0x00 0x01 0x00 0x00 0x00 0x08 0x00 0x00 0x00 0x15 0x01 0x03
0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x16 0x01 0x03 0x00 0x01
0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x17 0x01 0x04 0x00 0x01 0x00 0x00
0x00 0x01 0x00 0x00 0x00 0x1c 0x01 0x03 0x00 0x01 0x00 0x00 0x00 0x00
0x00 0x01 0x00 0x0e 0x83 0x0c 0x00 0x03 0x00 0x00 0x00 0xc4 0x00 0x00
0x00 0x82 0x84 0x0c 0x00 0x06 0x00 0x00 0x00 0xdc 0x00 0x00 0x00 0xaf
0x87 0x03 0x00 L 0x00 0x00 0x00 0x0c 0x01 0x00 0x00 0xb0 0x87 0x0c 0x00
0x06 0x00 0x00 0x00 0xa4 0x01 0x00 0x00 0xb1 0x87 0x02 0x00 0x1f 0x00
0x00 0x00 0xd4 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0xd0 ? 0x00 0x00 0x00 0x00 0x00 0x00 0xd0 ? 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0xa2 E 0xb6 0xf3 M' 0x85 0xc0 0x00 : 0xcc '& 0x89 0x14 0xc1 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x00 0x00 0x12
0x00 0x00 0x04 0x00 0x00 0x01 0x00 0x01 0x00 0x01 0x04 0x00 0x00 0x01
0x00 0x01 0x00 0x02 0x04 0xb1 0x87 0x15 0x00 0x00 0x00 0x00 0x08 0x00
0x00 0x01 0x00 0xff 0x7f 0x01 0x08 0xb1 0x87 0x09 0x00 0x15 0x00 0x02
0x08 0x00 0x00 0x01 0x00 0xff 0x7f 0x06 0x08 0x00 0x00 0x01 0x00 0x8e #
0x08 0x08 0x00 0x00 0x01 0x00 0xff 0x7f 0x09 0x08 0xb0 0x87 0x01 0x00
0x04 0x00 0x0a 0x08 0xb0 0x87 0x01 0x00 0x05 0x00 0x00 0x0c 0x00 0x00
0x01 0x00 0xff 0x7f 0x02 0x0c 0x00 0x00 0x01 0x00 0xff 0x7f 0x03 0x0c
0x00 0x00 0x01 0x00 0x11 0x00 0x04 0x0c 0x00 0x00 0x01 0x00 )# 0x0a
0x0c 0xb0 0x87 0x01 0x00 0x02 0x00 0x0b 0x0c 0xb0 0x87 0x01 0x00 0x03
0x00 0x10 0x0c 0xb0 0x87 0x01 0x00 0x01 0x00 0x11 0x0c 0xb0 0x87 0x01
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x14 0xc0 % 0x06 0x81 0x95
C 0xdb R 0xc0 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 Nb 0x10 h 0xe2 0xe8 IANb 0x10 h 0xe2 0xe8
IAEquirectangular MARS|GCS_MARS| 0x00

Bradford Castalia
Senior Systems Analyst
Planetary Image Research Laboratory
University of Arizona

Change History (2)

comment:1 by warmerdam, 17 years ago

Description: modified (diff)
Priority: highesthigh
Severity: blockermajor
Status: newassigned

comment:2 by warmerdam, 17 years ago

Description: modified (diff)

Bradford,

I'm not at all clear on why you write "GeoTIFF binary data should be MSB (high-endian) ordered."

On the face of it, I see no problem with LSB GeoTIFFs being generated on LSB platforms.

Note: See TracTickets for help on using tickets.