+
+ECW 5.x SDK provides amended file format which allows to store data statistics
+and supports UInt16 as band data type. To turn on writing ECW Version 3 files
+
Files to be compressed into ECW format must also
-be at least 128x128. ECW currently only supports 8 bits per channel.
+be at least 128x128. ECW currently only supports 8 bits per channel for
+ECW Version 2 files. ECW Version 3 files supports 16 bits per channel
+(as Uint16 data type). Please see Creation option to enable ECW V3 files writing
When writing coordinate system information to ECW files, many less
common coordinate systems are not mapped properly. If you know the
@@ -88,6 +96,10 @@
the name used by ERDAS in issuing the OEM key. It may also be provided
globally as a configuration option.
ECWV3=OFF: When build with the ECW 5.x SDK this option can be set to
+allow ECW Version 3 files to be created. This would allow to write UInt16 data type
+rasters (new feature of ECW Version 3 files) . Default is OFF which will write ECW Version 2 files.
+
ECW format does not support creation of overviews since the ECW format
Index: gdal/frmts/ecw/gdal_ecw.h
===================================================================
--- gdal/frmts/ecw/gdal_ecw.h (revision 25739)
+++ gdal/frmts/ecw/gdal_ecw.h (working copy)
@@ -78,7 +78,7 @@
#else
#if ECWSDK_VERSION>=50
#include
- #include "NCSEcw/JP2/File.h"
+ #include "NCSEcw/SDK/Box.h"
#else
#include
#endif
@@ -98,6 +98,8 @@
void ECWInitialize( void );
GDALDataset* ECWDatasetOpenJPEG2000(GDALOpenInfo* poOpenInfo);
+const char* ECWGetColorInterpretationName(GDALColorInterp eColorInterpretation, int nBandNumber);
+GDALColorInterp ECWGetColorInterpretationByName(const char *pszName);
#ifdef HAVE_COMPRESS
GDALDataset *
@@ -140,10 +142,10 @@
virtual ~JP2UserBox();
#if ECWSDK_VERSION >= 40
- virtual CNCSError Parse( NCS::JP2::CFile &JP2File,
+ virtual CNCSError Parse(NCS::SDK::CFileBase &JP2File,
NCS::CIOStream &Stream);
- virtual CNCSError UnParse( NCS::JP2::CFile &JP2File,
- NCS::CIOStream &Stream);
+ virtual CNCSError UnParse(NCS::SDK::CFileBase &JP2File,
+ NCS::CIOStream &Stream);
#else
virtual CNCSError Parse(class CNCSJP2File &JP2File,
CNCSJPCIOStream &Stream);
@@ -168,16 +170,17 @@
class VSIIOStream : public CNCSJPCIOStream
{
+ private:
+ char *m_Filename;
public:
INT64 startOfJPData;
INT64 lengthOfJPData;
VSILFILE *fpVSIL;
int bWritable;
- int nFileViewCount;
- char *pszFilename;
+ int nFileViewCount;
- VSIIOStream() {
+ VSIIOStream() : m_Filename(NULL){
nFileViewCount = 0;
startOfJPData = 0;
lengthOfJPData = -1;
@@ -185,6 +188,9 @@
}
virtual ~VSIIOStream() {
Close();
+ if (m_Filename!=NULL){
+ CPLFree(m_Filename);
+ }
}
virtual CNCSError Close() {
@@ -199,18 +205,18 @@
#if ECWSDK_VERSION >= 40
virtual VSIIOStream *Clone() {
- VSILFILE *fpNewVSIL = VSIFOpenL( m_Name.a_str(), "rb" );
+
+ VSILFILE *fpNewVSIL = VSIFOpenL( m_Filename, "rb" );
if (fpNewVSIL == NULL)
{
return NULL;
- }
- else
+ }else
{
VSIIOStream *pDst = new VSIIOStream();
- pDst->Access(fpNewVSIL, bWritable, m_Name.a_str(), startOfJPData, lengthOfJPData);
+ pDst->Access(fpNewVSIL, bWritable, m_Filename, startOfJPData, lengthOfJPData);
return pDst;
}
- }
+ }
#endif /* ECWSDK_VERSION >= 4 */
virtual CNCSError Access( VSILFILE *fpVSILIn, BOOLEAN bWrite,
@@ -222,7 +228,8 @@
lengthOfJPData = size;
bWritable = bWrite;
VSIFSeekL(fpVSIL, startOfJPData, SEEK_SET);
-
+ m_Filename = (char *)CPLMalloc(strlen(pszFilename)+1);
+ strncpy(m_Filename, pszFilename, strlen(pszFilename)+1);
// the filename is used to establish where to put temporary files.
// if it does not have a path to a real directory, we will
// substitute something.
@@ -419,9 +426,21 @@
int, int *, int, int, int );
CPLErr LoadNextLine();
+#if ECWSDK_VERSION>=50
+
+ NCSFileStatistics* pStatistics;
+ int bStatisticsDirty;
+ int bStatisticsInitialized;
+ NCS::CError StatisticsEnsureInitialized();
+ NCS::CError StatisticsWrite();
+ void CleanupStatistics();
+
+#endif
+
static CNCSJP2FileView *OpenFileView( const char *pszDatasetName,
bool bProgressive,
- int &bUsingCustomStream );
+ int &bUsingCustomStream,
+ bool bWrite=false);
int bHdrDirty;
CPLString m_osDatumCode;
@@ -446,8 +465,8 @@
int nBandCount,
int nPixelSpace, int nLineSpace, int nBandSpace);
public:
- ECWDataset(int bIsJPEG2000);
- ~ECWDataset();
+ ECWDataset(int bIsJPEG2000);
+ ~ECWDataset();
static GDALDataset *Open( GDALOpenInfo *, int bIsJPEG2000 );
static int IdentifyJPEG2000( GDALOpenInfo * poOpenInfo );
@@ -519,6 +538,13 @@
std::vector apoOverviews;
+#if ECWSDK_VERSION>=50
+
+ int nStatsBandIndex;
+ int nStatsBandCount;
+
+#endif
+
//#if !defined(SDK_CAN_DO_SUPERSAMPLING)
CPLErr OldIRasterIO( GDALRWFlag, int, int, int, int,
void *, int, int, GDALDataType,
@@ -545,6 +571,21 @@
virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
int nBufXSize, int nBufYSize,
GDALDataType eDT, char **papszOptions );
+#if ECWSDK_VERSION >= 50
+ void GetBandIndexAndCountForStatistics(int &bandIndex, int &bandCount);
+ virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
+ int *pnBuckets, int ** ppanHistogram,
+ int bForce,
+ GDALProgressFunc, void *pProgressData);
+ virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
+ int nBuckets, int *panHistogram );
+ virtual CPLErr GetStatistics( int bApproxOK, int bForce,
+ double *pdfMin, double *pdfMax,
+ double *pdfMean, double *padfStdDev );
+ virtual CPLErr SetStatistics( double dfMin, double dfMax,
+ double dfMean, double dfStdDev );
+#endif
+
};
int ECWTranslateFromWKT( const char *pszWKT,
Index: gdal/frmts/ecw/jp2userbox.cpp
===================================================================
--- gdal/frmts/ecw/jp2userbox.cpp (revision 25739)
+++ gdal/frmts/ecw/jp2userbox.cpp (working copy)
@@ -94,7 +94,7 @@
/************************************************************************/
#if ECWSDK_VERSION >= 40
-CNCSError JP2UserBox::Parse( NCS::JP2::CFile &JP2File,
+CNCSError JP2UserBox::Parse( NCS::SDK::CFileBase &JP2File,
NCS::CIOStream &Stream )
#else
CNCSError JP2UserBox::Parse( class CNCSJP2File &JP2File,
@@ -113,7 +113,7 @@
/************************************************************************/
#if ECWSDK_VERSION >= 40
-CNCSError JP2UserBox::UnParse( NCS::JP2::CFile &JP2File,
+CNCSError JP2UserBox::UnParse( NCS::SDK::CFileBase &JP2File,
NCS::CIOStream &Stream )
#else
CNCSError JP2UserBox::UnParse( class CNCSJP2File &JP2File,