Opened 12 years ago

Closed 11 years ago

Last modified 10 years ago

#4866 closed enhancement (fixed)

Create Pyramid layers with the same compressed setting as the band for HFA

Reported by: Sam Gillingham Owned by: warmerdam
Priority: normal Milestone: 1.11.0
Component: GDAL_Raster Version: 1.9.2
Severity: normal Keywords: HFA
Cc:

Description

Attached patch makes the Pyramid layers compressed if the source band is compressed. This is what Imagine does, and can make resulting files much smaller.

Attachments (3)

hfaband.cpp.compresspyramids.1.9.1.patch (1.3 KB ) - added by Sam Gillingham 12 years ago.
Patch to hfaband.cpp to make pyramid layers compressed if band is compressed
hfaband.cpp.compresspyramids.patch (1.3 KB ) - added by Sam Gillingham 11 years ago.
Updated against trunk
frmt_hfa.html.patch (630 bytes ) - added by Sam Gillingham 11 years ago.
Patch to document behaviour of HFA_COMPRESS_OVR config option in frmt_hfa.html

Download all attachments as: .zip

Change History (11)

by Sam Gillingham, 12 years ago

Patch to hfaband.cpp to make pyramid layers compressed if band is compressed

by Sam Gillingham, 11 years ago

Updated against trunk

comment:1 by Sam Gillingham, 11 years ago

Just updated the patch against trunk. Any feedback on this ticket?

comment:2 by Even Rouault, 11 years ago

I'm wondering if we shouldn't look at a HFA_COMPRESS_OVR configuration option first. If not defined, then take the compression mode from the full resolution image like your proposed patch.

The advantage of the configuration option is that it can also be used when building .aux external overviews for other formats.

e.g: gdaladdo out.tif --config USE_RRD YES 2 --config HFA_COMPRESS_OVR YES

Modified patch :

Index: frmts/hfa/hfaband.cpp
===================================================================
--- frmts/hfa/hfaband.cpp	(révision 26132)
+++ frmts/hfa/hfaband.cpp	(copie de travail)
@@ -2059,12 +2059,29 @@
     }
 
 /* -------------------------------------------------------------------- */
+/*      Are we compressed? If so, overview should be too (unless        */
+/*      HFA_COMPRESS_OVR is defined).                                   */
+/*      Check RasterDMS like HFAGetBandInfo                             */
+/* -------------------------------------------------------------------- */
+    int bCompressionType = FALSE;
+    const char* pszCompressOvr = CPLGetConfigOption("HFA_COMPRESS_OVR", NULL);
+    if( pszCompressOvr != NULL )
+        bCompressionType = CSLTestBoolean(pszCompressOvr);
+    else
+    {
+        HFAEntry *poDMS = poNode->GetNamedChild( "RasterDMS" );
+
+        if( poDMS != NULL )
+            bCompressionType = poDMS->GetIntField( "compressionType" ) != 0;
+    }
+
+/* -------------------------------------------------------------------- */
 /*      Create the layer.                                               */
 /* -------------------------------------------------------------------- */
     osLayerName.Printf( "_ss_%d_", nOverviewLevel );
 
     if( !HFACreateLayer( psRRDInfo, poParent, osLayerName, 
-                         TRUE, 64, FALSE, bCreateLargeRaster, FALSE,
+                         TRUE, 64, bCompressionType, bCreateLargeRaster, FALSE,
                          nOXSize, nOYSize, nOverviewDataType, NULL,
                          nValidFlagsOffset, nDataOffset, 1, 0 ) )
         return -1;

What do you think of that ? It would be appropriate too to modify the frmt_hfa.html file to document the above behaviour.

comment:3 by Sam Gillingham, 11 years ago

Sounds like an excellent idea to me! It definitely would be useful to be able to compress .aux overviews also.

comment:4 by Sam Gillingham, 11 years ago

Have attached patch for frmt_hfa.html. Let me know if any other work is required to have this change accepted.

comment:5 by Even Rouault, 11 years ago

There's an error in the doc patch. HFA_COMPRESS_OVR is a configuration option (i.e. something you can define with --config HFA_COMPRESS_OVR YES on a GDAL command line, or through an environmenet variable), and not a creation option of the driver (i.e. something you pass with -co NAME=VALUE)

by Sam Gillingham, 11 years ago

Attachment: frmt_hfa.html.patch added

Patch to document behaviour of HFA_COMPRESS_OVR config option in frmt_hfa.html

comment:6 by Sam Gillingham, 11 years ago

Doc patch updated.

comment:7 by Even Rouault, 11 years ago

Milestone: 2.0
Resolution: fixed
Status: newclosed

Pushed in r26190.

comment:8 by Even Rouault, 10 years ago

Milestone: 2.01.11.0
Note: See TracTickets for help on using tickets.