Opened 12 years ago

Closed 12 years ago

#4371 closed defect (fixed)

NitfDataset cannot update COMRAT for images with comments

Reported by: jeepingben Owned by: warmerdam
Priority: normal Milestone: 1.9.0
Component: default Version: svn-trunk
Severity: normal Keywords:
Cc:

Description

I found this while writing Nitf images with JPEG2000 compression. If the image contains comments, the code around nitfdataset.cpp:4569 will not find IC, so it will not know where to put the updated COMRAT information. An error is displayed:

Warning 1: Unable to locate COMRAT to update in NITF header.

In addition to checking offset 778 and 838, it needs to check each multiple of 80 bytes away from each of those offsets. This would be dangerous in the case where a comment began with the IC value for the image.

It would probably be safer to examine ICORD (offset 776), then if there is an IGEOLO, skip it and read NICOM, then skip 80 * NICOM bytes to check for IC.

Change History (4)

comment:1 by Even Rouault, 12 years ago

I've pushed r23482 /trunk/gdal/frmts/nitf/nitfdataset.cpp: NITF: take into account the presence of comments when patching COMRAT for JPEG/JPEG2000 NITF (#4371)

My testing shows it works. Would be great if you could confirm.

comment:2 by Even Rouault, 12 years ago

r23483 /trunk/gdal/frmts/nitf/nitfdataset.cpp: NITF: fix comments and variable name

comment:3 by jeepingben, 12 years ago

Thanks for the fix. Your changes work for me, but I think you missed the case of NITF2.0 with no IGEOLO, ICORDS will be 'N' in that case. 'N' is north for NITF2.1, so the check would have to be FHDR=="NITF02.00" && ICORD=='N' unless NITF dataset always carries the NITF2.1 version of ICORD.

Thanks again, Ben

comment:4 by Even Rouault, 12 years ago

Milestone: 1.9.0
Resolution: fixed
Status: newclosed

Good point, but after checking, NITFCreate() only supports NITF 2.1 / NSIF 1.0. See nitffile.c, around line 735

Note: See TracTickets for help on using tickets.