Skip to content

Commit

Permalink
ENH: Remove hard-coded pixel function now that we have them within gdal
Browse files Browse the repository at this point in the history
  • Loading branch information
jmichel-otb committed Jul 7, 2016
1 parent 07eae9f commit f264169
Showing 1 changed file with 1 addition and 55 deletions.
56 changes: 1 addition & 55 deletions gdal/frmts/cderived/cderiveddataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,6 @@

#include <iostream>

CPLErr ModulePixelFunc(void **papoSources, int nSources, void *pData,
int nXSize, int nYSize,
GDALDataType eSrcType, GDALDataType eBufType,
int nPixelSpace, int nLineSpace)
{
int ii, iLine, iCol;
double dfPixVal;

/* ---- Init ---- */
if (nSources != 1) return CE_Failure;

if (GDALDataTypeIsComplex( eSrcType ))
{
double dfReal, dfImag;
void *pReal = papoSources[0];
void *pImag = ((GByte *)papoSources[0])
+ GDALGetDataTypeSize( eSrcType ) / 8 / 2;

/* ---- Set pixels ---- */
for( iLine = 0, ii = 0; iLine < nYSize; ++iLine ) {
for( iCol = 0; iCol < nXSize; ++iCol, ++ii ) {

/* Source raster pixels may be obtained with SRCVAL macro */
dfReal = SRCVAL(pReal, eSrcType, ii);
dfImag = SRCVAL(pImag, eSrcType, ii);

dfPixVal = sqrt( dfReal * dfReal + dfImag * dfImag );

GDALCopyWords(&dfPixVal, GDT_Float64, 0,
((GByte *)pData) + nLineSpace * iLine +
iCol * nPixelSpace, eBufType, nPixelSpace, 1);
}
}
} else {
/* ---- Set pixels ---- */
for( iLine = 0, ii = 0; iLine < nYSize; ++iLine ) {
for( iCol = 0; iCol < nXSize; ++iCol, ++ii ) {

/* Source raster pixels may be obtained with SRCVAL macro */
dfPixVal = fabs(SRCVAL(papoSources[0], eSrcType, ii));

GDALCopyWords(&dfPixVal, GDT_Float64, 0,
((GByte *)pData) + nLineSpace * iLine +
iCol * nPixelSpace, eBufType, nPixelSpace, 1);
}
}
}

/* ---- Return success ---- */
return CE_None;
} /* ModulePixelFunc */


class ComplexDerivedDatasetContainer: public GDALPamDataset
{
Expand Down Expand Up @@ -121,9 +69,7 @@ GDALDataset * ComplexDerivedDataset::Open(GDALOpenInfo * poOpenInfo)
/* Unable to Open in this case */
return NULL;
}

VRTDerivedRasterBand::AddPixelFunction("mod",ModulePixelFunc);


CPLString odFilename = filename.substr(alg_pos+1,filename.size() - alg_pos);

GDALDataset * poTmpDS = (GDALDataset*)GDALOpen(odFilename, GA_ReadOnly);
Expand Down

0 comments on commit f264169

Please sign in to comment.