[gdal-dev] Setting "INIT_DEST" to nan on windows

Even Rouault even.rouault at mines-paris.org
Thu May 5 14:21:59 EDT 2011


Le mercredi 04 mai 2011 00:40:42, Kyle Shannon a écrit :
> I am using AutoCreateWarpedVRT to warp a dataset.  I grab the the source
> nodata for a band using
> 
> double noData = poBand->GetNoDataValue( &pbSuccess );
> 
> which returns 1.#QNAN00000000... on windows.
> 
> I then try to set the INIT_DEST with this using
> 
> psWarpOptions->papszWarpOptions =
>         CSLSetNameValue( psWarpOptions->papszWarpOptions,
>                  "INIT_DEST", CPLSPrintf( "%lf", noData ) );
> 
> This works on linux when it returns nan(0x8000000000000), but not on
> windows, is there a different string I need to set in the warp options?

Those NaN values are generally a nighmare to deal with...

But a quick look at :

    const char *pszInitDest = CSLFetchNameValue( psOptions->papszWarpOptions,
                                                 "INIT_DEST" );

    if( pszInitDest != NULL && !EQUAL(pszInitDest, "") )
    {
        char **papszInitValues = 
            CSLTokenizeStringComplex( pszInitDest, ",", FALSE, FALSE );
        int nInitCount = CSLCount(papszInitValues);
                                                           
        for( iBand = 0; iBand < psOptions->nBandCount; iBand++ )
        {
            double adfInitRealImag[2];
            GByte *pBandData;
            const char *pszBandInit = 
papszInitValues[MIN(iBand,nInitCount-1)];

            if( EQUAL(pszBandInit,"NO_DATA")
                && psOptions->padfDstNoDataReal != NULL )
            {
                adfInitRealImag[0] = psOptions->padfDstNoDataReal[iBand];
                adfInitRealImag[1] = psOptions->padfDstNoDataImag[iBand];
            }
            else
            {
                CPLStringToComplex( pszBandInit,
                                    adfInitRealImag + 0, adfInitRealImag + 1);
            }

Make me believe that one way is to assign the value(s) of the 
padfDstNoDataReal[] array of psWarpOptions with the noData (NAN) value and set 
INIT_DEST to the "NO_DATA" string.

> 
> Thanks.
> 
> 
> /**
>  *
>  * Kyle Shannon
>  * ksshannon at gmail.com
>  *
>  */


More information about the gdal-dev mailing list