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

« back to all changes in this revision

Viewing changes to alg/polygonize.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: polygonize.cpp 18523 2010-01-11 18:12:25Z mloskot $
 
2
 * $Id: polygonize.cpp 22501 2011-06-04 21:28:47Z rouault $
3
3
 * Project:  GDAL
4
4
 * Purpose:  Raster to Polygon Converter
5
5
 * Author:   Frank Warmerdam, warmerdam@pobox.com
28
28
 
29
29
#include "gdal_alg_priv.h"
30
30
#include "cpl_conv.h"
 
31
#include "cpl_string.h"
31
32
#include <vector>
32
33
 
33
 
CPL_CVSID("$Id: polygonize.cpp 18523 2010-01-11 18:12:25Z mloskot $");
 
34
CPL_CVSID("$Id: polygonize.cpp 22501 2011-06-04 21:28:47Z rouault $");
34
35
 
35
36
#define GP_NODATA_MARKER -51502112
36
37
 
 
38
#ifdef OGR_ENABLED
 
39
 
37
40
/************************************************************************/
38
41
/* ==================================================================== */
39
42
/*                               RPolygon                               */
427
430
 
428
431
    return eErr;
429
432
}
430
 
 
 
433
#endif // OGR_ENABLED
 
434
 
431
435
/************************************************************************/
432
436
/*                           GDALPolygonize()                           */
433
437
/************************************************************************/
442
446
 *
443
447
 * Note that currently the source pixel band values are read into a
444
448
 * signed 32bit integer buffer (Int32), so floating point or complex 
445
 
 * bands will be implicitly truncated before processing.  
 
449
 * bands will be implicitly truncated before processing. If you want to use a
 
450
 * version using 32bit float buffers, see GDALFPolygonize() at fpolygonize.cpp.
446
451
 *
447
452
 * Polygon features will be created on the output layer, with polygon 
448
453
 * geometries representing the polygons.  The polygon geometries will be
473
478
 * be written. 
474
479
 * @param iPixValField the attribute field index indicating the feature
475
480
 * attribute into which the pixel value of the polygon should be written.
476
 
 * @param papszOptions a name/value list of additional options (none currently
477
 
 * supported). 
 
481
 * @param papszOptions a name/value list of additional options
 
482
 * <dl>
 
483
 * <dt>"8CONNECTED":</dt> May be set to "8" to use 8 connectedness.
 
484
 * Otherwise 4 connectedness will be applied to the algorithm
 
485
 * </dl>
478
486
 * @param pfnProgress callback for reporting algorithm progress matching the
479
487
 * GDALProgressFunc() semantics.  May be NULL.
480
488
 * @param pProgressArg callback argument passed to pfnProgress.
491
499
                void * pProgressArg )
492
500
 
493
501
{
 
502
#ifndef OGR_ENABLED
 
503
    CPLError(CE_Failure, CPLE_NotSupported, "GDALPolygonize() unimplemented in a non OGR build");
 
504
    return CE_Failure;
 
505
#else
494
506
    VALIDATE_POINTER1( hSrcBand, "GDALPolygonize", CE_Failure );
495
507
    VALIDATE_POINTER1( hOutLayer, "GDALPolygonize", CE_Failure );
496
508
 
497
509
    if( pfnProgress == NULL )
498
510
        pfnProgress = GDALDummyProgress;
499
511
 
 
512
    int nConnectedness = CSLFetchNameValue( papszOptions, "8CONNECTED" ) ? 8 : 4;
 
513
 
500
514
/* -------------------------------------------------------------------- */
501
515
/*      Confirm our output layer will support feature creation.         */
502
516
/* -------------------------------------------------------------------- */
549
563
/*      what on the second pass.                                        */
550
564
/* -------------------------------------------------------------------- */
551
565
    int iY;
552
 
    GDALRasterPolygonEnumerator oFirstEnum;
 
566
    GDALRasterPolygonEnumerator oFirstEnum(nConnectedness);
553
567
 
554
568
    for( iY = 0; eErr == CE_None && iY < nYSize; iY++ )
555
569
    {
615
629
/*      We will use a new enumerator for the second pass primariliy     */
616
630
/*      so we can preserve the first pass map.                          */
617
631
/* -------------------------------------------------------------------- */
618
 
    GDALRasterPolygonEnumerator oSecondEnum;
 
632
    GDALRasterPolygonEnumerator oSecondEnum(nConnectedness);
619
633
    RPolygon **papoPoly = (RPolygon **) 
620
634
        CPLCalloc(sizeof(RPolygon*),oFirstEnum.nNextPolygonId);
621
635
 
749
763
    CPLFree( papoPoly );
750
764
 
751
765
    return eErr;
 
766
#endif // OGR_ENABLED
752
767
}
753
768