Changeset 14724
- Timestamp:
- 06/18/08 16:20:38 (6 months ago)
- Files:
-
- trunk/gdal/frmts/aaigrid/aaigriddataset.cpp (modified) (3 diffs)
- trunk/gdal/frmts/frmt_various.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/frmts/aaigrid/aaigriddataset.cpp
r14478 r14724 768 768 769 769 /* -------------------------------------------------------------------- */ 770 /* Builds the format string used for printing float values. */ 771 /* -------------------------------------------------------------------- */ 772 char szFormatFloat[32]; 773 strcpy(szFormatFloat, " %6.20g"); 774 const char *pszDecimalPrecision = 775 CSLFetchNameValue( papszOptions, "DECIMAL_PRECISION" ); 776 if (pszDecimalPrecision) 777 { 778 int nDecimal = atoi(pszDecimalPrecision); 779 if (nDecimal >= 0) 780 sprintf(szFormatFloat, " %%.%df", nDecimal); 781 } 782 783 /* -------------------------------------------------------------------- */ 770 784 /* Loop over image, copying image data. */ 771 785 /* -------------------------------------------------------------------- */ … … 814 828 for ( iPixel = 0; iPixel < nXSize; iPixel++ ) 815 829 { 816 sprintf( szHeader, " %6.20g", padfScanline[iPixel] );830 sprintf( szHeader, szFormatFloat, padfScanline[iPixel] ); 817 831 if( VSIFWriteL( szHeader, strlen(szHeader), 1, fpImage ) != 1 ) 818 832 { … … 953 967 "<CreationOptionList>\n" 954 968 " <Option name='FORCE_CELLSIZE' type='boolean' description='Force use of CELLSIZE, default is FALSE.'/>\n" 969 " <Option name='DECIMAL_PRECISION' type='int' description='Number of decimal when writing floating-point numbers.'/>\n" 955 970 "</CreationOptionList>\n" ); 956 971 trunk/gdal/frmts/frmt_various.html
r14557 r14724 30 30 use the FORCE_CELLSIZE=YES creation option or resample the input to have 31 31 square pixels.<P> 32 33 When writing floating-point values, the driver uses the "%6.20g" format 34 pattern as a default. You can consult a <a href="http://en.wikipedia.org/wiki/Printf"> 35 reference manual</a> for printf to have an idea of the exact behaviour of this ;-). 36 You can alternatively specify the number of decimal places with the DECIMAL_PRECISION creation 37 option. For example, DECIMAL_PRECISION=3 will output numbers with 3 decimal places.<p> 32 38 33 39 The <a href="#AIG">AIG</a> driver is also available
