~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to alg/gdalrasterize.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: gdalrasterize.cpp 19079 2010-03-14 16:37:15Z chaitanya $
 
2
 * $Id: gdalrasterize.cpp 23250 2011-10-18 19:05:02Z rouault $
3
3
 *
4
4
 * Project:  GDAL
5
5
 * Purpose:  Vector rasterization.
81
81
            memset( pabyInsert, nBurnValue, nXEnd - nXStart + 1 );
82
82
        }
83
83
    }
84
 
    else
 
84
    else if( psInfo->eType == GDT_Float64 )
85
85
    {
86
86
        for( iBand = 0; iBand < psInfo->nBands; iBand++ )
87
87
        {
88
88
            int nPixels = nXEnd - nXStart + 1;
89
 
            float   *pafInsert;
90
 
            float   fBurnValue = (float)
 
89
            double   *padfInsert;
 
90
            double   dfBurnValue = 
91
91
                ( psInfo->padfBurnValue[iBand] +
92
92
                  ( (psInfo->eBurnValueSource == GBV_UserBurnValue)?
93
93
                             0 : dfVariant ) );
94
94
            
95
 
            pafInsert = ((float *) psInfo->pabyChunkBuf) 
 
95
            padfInsert = ((double *) psInfo->pabyChunkBuf)
96
96
                + iBand * psInfo->nXSize * psInfo->nYSize
97
97
                + nY * psInfo->nXSize + nXStart;
98
98
 
99
99
            while( nPixels-- > 0 )
100
 
                *(pafInsert++) = fBurnValue;
 
100
                *(padfInsert++) = dfBurnValue;
101
101
        }
102
102
    }
 
103
    else
 
104
        CPLAssert(0);
103
105
}
104
106
 
105
107
/************************************************************************/
128
130
                             0 : dfVariant ) );
129
131
        }
130
132
    }
131
 
    else
 
133
    else if( psInfo->eType == GDT_Float64 )
132
134
    {
133
135
        for( iBand = 0; iBand < psInfo->nBands; iBand++ )
134
136
        {
135
 
            float   *pfInsert = ((float *) psInfo->pabyChunkBuf) 
 
137
            double   *pdfInsert = ((double *) psInfo->pabyChunkBuf)
136
138
                                + iBand * psInfo->nXSize * psInfo->nYSize
137
139
                                + nY * psInfo->nXSize + nX;
138
140
 
139
 
            *pfInsert = (float)( psInfo->padfBurnValue[iBand] +
 
141
            *pdfInsert = ( psInfo->padfBurnValue[iBand] +
140
142
                         ( (psInfo->eBurnValueSource == GBV_UserBurnValue)?
141
143
                            0 : dfVariant ) );
142
144
        }
143
145
    }
 
146
    else
 
147
        CPLAssert(0);
144
148
}
145
149
 
146
150
/************************************************************************/
336
340
/*      According to the C++ Standard/23.2.4, elements of a vector are  */
337
341
/*      stored in continuous memory block.                              */
338
342
/* -------------------------------------------------------------------- */
339
 
    unsigned int j,n;
340
343
 
341
344
    // TODO - mloskot: Check if vectors are empty, otherwise it may
342
345
    // lead to undefined behavior by returning non-referencable pointer.
343
346
    // if (!aPointX.empty())
344
347
    //    /* fill polygon */
345
348
    // else
346
 
    //    /* How to report this problem? */    
 
349
    //    /* How to report this problem? */
347
350
    switch ( wkbFlatten(poShape->getGeometryType()) )
348
351
    {
349
352
        case wkbPoint:
399
402
                }
400
403
                else
401
404
                {
402
 
                for( i = 0, n = 0; i < aPartSize.size(); i++ )
403
 
                    for( j = 0; j < aPartSize[i]; j++ )
404
 
                        aPointVariant[n++] = aPointVariant[0];
405
 
                   
406
 
                GDALdllImageLineAllTouched( sInfo.nXSize, nYSize, 
407
 
                                            aPartSize.size(), &(aPartSize[0]), 
408
 
                                            &(aPointX[0]), &(aPointY[0]), 
409
 
                                            &(aPointVariant[0]),
410
 
                                            gvBurnPoint, &sInfo );
 
405
                    unsigned int n;
 
406
                    for ( i = 0, n = 0; i < aPartSize.size(); i++ )
 
407
                    {
 
408
                        int j;
 
409
                        for ( j = 0; j < aPartSize[i]; j++ )
 
410
                            aPointVariant[n++] = aPointVariant[0];
 
411
                    }
 
412
 
 
413
                    GDALdllImageLineAllTouched( sInfo.nXSize, nYSize, 
 
414
                                                aPartSize.size(), &(aPartSize[0]), 
 
415
                                                &(aPointX[0]), &(aPointY[0]), 
 
416
                                                &(aPointVariant[0]),
 
417
                                                gvBurnPoint, &sInfo );
411
418
                }
412
419
            }
413
420
        }
447
454
 * @param pfnTransformer transformation to apply to geometries to put into 
448
455
 * pixel/line coordinates on raster.  If NULL a geotransform based one will
449
456
 * be created internally.
450
 
 * @param pTransformerArg callback data for transformer.
 
457
 * @param pTransformArg callback data for transformer.
451
458
 * @param padfGeomBurnValue the array of values to burn into the raster.  
452
459
 * There should be nBandCount values for each geometry. 
453
460
 * @param papszOptions special options controlling rasterization
537
544
    if( poBand->GetRasterDataType() == GDT_Byte )
538
545
        eType = GDT_Byte;
539
546
    else
540
 
        eType = GDT_Float32;
 
547
        eType = GDT_Float64;
541
548
 
542
549
    nScanlineBytes = nBandCount * poDS->GetRasterXSize()
543
550
        * (GDALGetDataTypeSize(eType)/8);
646
653
 * @param pfnTransformer transformation to apply to geometries to put into 
647
654
 * pixel/line coordinates on raster.  If NULL a geotransform based one will
648
655
 * be created internally.
649
 
 * @param pTransformerArg callback data for transformer.
 
656
 * @param pTransformArg callback data for transformer.
650
657
 * @param padfLayerBurnValues the array of values to burn into the raster.  
651
658
 * There should be nBandCount values for each layer. 
652
 
 * @param papszOption special options controlling rasterization:
 
659
 * @param papszOptions special options controlling rasterization:
653
660
 * <dl>
654
661
 * <dt>"ATTRIBUTE":</dt> <dd>Identifies an attribute field on the features to be
655
662
 * used for a burn in value. The value will be burned into all output
676
683
 * @return CE_None on success or CE_Failure on error.
677
684
 */
678
685
 
679
 
#ifdef OGR_ENABLED
680
 
 
681
 
CPLErr GDALRasterizeLayers( GDALDatasetH hDS, 
 
686
CPLErr GDALRasterizeLayers( GDALDatasetH hDS,
682
687
                            int nBandCount, int *panBandList,
683
688
                            int nLayerCount, OGRLayerH *pahLayers,
684
689
                            GDALTransformerFunc pfnTransformer, 
689
694
                            void *pProgressArg )
690
695
 
691
696
{
 
697
#ifndef OGR_ENABLED
 
698
    CPLError(CE_Failure, CPLE_NotSupported, "GDALRasterizeLayers() unimplemented in a non OGR build");
 
699
    return CE_Failure;
 
700
#else
692
701
    GDALDataType   eType;
693
702
    unsigned char *pabyChunkBuf;
694
703
    GDALDataset *poDS = (GDALDataset *) hDS;
730
739
    if( poBand->GetRasterDataType() == GDT_Byte )
731
740
        eType = GDT_Byte;
732
741
    else
733
 
        eType = GDT_Float32;
 
742
        eType = GDT_Float64;
734
743
 
735
744
    nScanlineBytes = nBandCount * poDS->GetRasterXSize()
736
745
        * (GDALGetDataTypeSize(eType)/8);
737
746
 
738
 
    if ( pszYChunkSize && (nYChunkSize = atoi(pszYChunkSize)) )
 
747
    if ( pszYChunkSize && ((nYChunkSize = atoi(pszYChunkSize))) != 0 )
739
748
        ;
740
749
    else
741
 
        nYChunkSize = GDALGetCacheMax() / nScanlineBytes;
 
750
    {
 
751
        GIntBig nYChunkSize64 = GDALGetCacheMax64() / nScanlineBytes;
 
752
        if (nYChunkSize64 > INT_MAX)
 
753
            nYChunkSize = INT_MAX;
 
754
        else
 
755
            nYChunkSize = (int)nYChunkSize64;
 
756
    }
742
757
 
743
758
    if( nYChunkSize < 1 )
744
759
        nYChunkSize = 1;
958
973
    VSIFree( pabyChunkBuf );
959
974
    
960
975
    return eErr;
 
976
#endif /* def OGR_ENABLED */
961
977
}
962
978
 
963
 
#endif /* def OGR_ENABLED */
964
 
 
965
979
/************************************************************************/
966
980
/*                        GDALRasterizeLayersBuf()                      */
967
981
/************************************************************************/
1011
1025
 * pixel/line coordinates on raster.  If NULL a geotransform based one will
1012
1026
 * be created internally.
1013
1027
 *
1014
 
 * @param pTransformerArg callback data for transformer.
 
1028
 * @param pTransformArg callback data for transformer.
1015
1029
 *
1016
1030
 * @param dfBurnValue the value to burn into the raster.  
1017
1031
 *
1018
 
 * @param papszOption special options controlling rasterization:
 
1032
 * @param papszOptions special options controlling rasterization:
1019
1033
 * <dl>
1020
1034
 * <dt>"ATTRIBUTE":</dt> <dd>Identifies an attribute field on the features to be
1021
1035
 * used for a burn in value. The value will be burned into all output
1041
1055
 * @return CE_None on success or CE_Failure on error.
1042
1056
 */
1043
1057
 
1044
 
#ifdef OGR_ENABLED
1045
 
 
1046
1058
CPLErr GDALRasterizeLayersBuf( void *pData, int nBufXSize, int nBufYSize,
1047
1059
                               GDALDataType eBufType,
1048
1060
                               int nPixelSpace, int nLineSpace,
1056
1068
                               void *pProgressArg )
1057
1069
 
1058
1070
{
 
1071
#ifndef OGR_ENABLED
 
1072
    CPLError(CE_Failure, CPLE_NotSupported, "GDALRasterizeLayersBuf() unimplemented in a non OGR build");
 
1073
    return CE_Failure;
 
1074
#else
1059
1075
/* -------------------------------------------------------------------- */
1060
1076
/*      If pixel and line spaceing are defaulted assign reasonable      */
1061
1077
/*      value assuming a packed buffer.                                 */
1200
1216
    }
1201
1217
    
1202
1218
    return eErr;
 
1219
#endif /* def OGR_ENABLED */
1203
1220
}
1204
1221
 
1205
 
#endif /* def OGR_ENABLED */