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

« back to all changes in this revision

Viewing changes to apps/ogrinfo.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: ogrinfo.cpp 18306 2009-12-15 18:57:11Z rouault $
 
2
 * $Id: ogrinfo.cpp 23119 2011-09-24 16:15:21Z rouault $
3
3
 *
4
4
 * Project:  OpenGIS Simple Features Reference Implementation
5
5
 * Purpose:  Simple client for viewing OGR driver data.
34
34
#include "cpl_string.h"
35
35
#include "cpl_multiproc.h"
36
36
 
37
 
CPL_CVSID("$Id: ogrinfo.cpp 18306 2009-12-15 18:57:11Z rouault $");
 
37
CPL_CVSID("$Id: ogrinfo.cpp 23119 2011-09-24 16:15:21Z rouault $");
38
38
 
39
39
int     bReadOnly = FALSE;
40
40
int     bVerbose = TRUE;
60
60
    int         nRepeatCount = 1, bAllLayers = FALSE;
61
61
    const char  *pszSQLStatement = NULL;
62
62
    const char  *pszDialect = NULL;
 
63
    int          nRet = 0;
63
64
    
64
65
    /* Check strict compilation and runtime library version as we use C++ API */
65
66
    if (! GDAL_CHECK_VERSION(papszArgv[0]))
198
199
            printf( "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
199
200
        }
200
201
 
201
 
        exit( 1 );
 
202
        nRet = 1;
 
203
        goto end;
202
204
    }
203
205
 
204
206
    CPLAssert( poDriver != NULL);
236
238
        if( poResultSet != NULL )
237
239
        {
238
240
            if( pszWHERE != NULL )
239
 
                poResultSet->SetAttributeFilter( pszWHERE );
 
241
            {
 
242
                if (poResultSet->SetAttributeFilter( pszWHERE ) != OGRERR_NONE )
 
243
                {
 
244
                    printf( "FAILURE: SetAttributeFilter(%s) failed.\n", pszWHERE );
 
245
                    exit(1);
 
246
                }
 
247
            }
240
248
 
241
249
            ReportOnLayer( poResultSet, NULL, NULL );
242
250
            poDS->ReleaseResultSet( poResultSet );
267
275
                {
268
276
                    printf( "%d: %s",
269
277
                            iLayer+1,
270
 
                            poLayer->GetLayerDefn()->GetName() );
 
278
                            poLayer->GetName() );
271
279
 
272
 
                    if( poLayer->GetLayerDefn()->GetGeomType() != wkbUnknown )
 
280
                    if( poLayer->GetGeomType() != wkbUnknown )
273
281
                        printf( " (%s)", 
274
282
                                OGRGeometryTypeToName( 
275
 
                                    poLayer->GetLayerDefn()->GetGeomType() ) );
 
283
                                    poLayer->GetGeomType() ) );
276
284
 
277
285
                    printf( "\n" );
278
286
                }
313
321
/* -------------------------------------------------------------------- */
314
322
/*      Close down.                                                     */
315
323
/* -------------------------------------------------------------------- */
 
324
end:
316
325
    CSLDestroy( papszArgv );
317
326
    CSLDestroy( papszLayers );
318
327
    CSLDestroy( papszOptions );
322
331
 
323
332
    OGRCleanupAll();
324
333
 
325
 
    return 0;
 
334
    return nRet;
326
335
}
327
336
 
328
337
/************************************************************************/
334
343
{
335
344
    printf( "Usage: ogrinfo [--help-general] [-ro] [-q] [-where restricted_where]\n"
336
345
            "               [-spat xmin ymin xmax ymax] [-fid fid]\n"
337
 
            "               [-sql statement] [-al] [-so] [-fields={YES/NO}]\n"
 
346
            "               [-sql statement] [-dialect sql_dialect] [-al] [-so] [-fields={YES/NO}]\n"
338
347
            "               [-geom={YES/NO/SUMMARY}][--formats]\n"
339
348
            "               datasource_name [layer [layer ...]]\n");
340
349
    exit( 1 );
354
363
/*      Set filters if provided.                                        */
355
364
/* -------------------------------------------------------------------- */
356
365
    if( pszWHERE != NULL )
357
 
        poLayer->SetAttributeFilter( pszWHERE );
 
366
    {
 
367
        if (poLayer->SetAttributeFilter( pszWHERE ) != OGRERR_NONE )
 
368
        {
 
369
            printf( "FAILURE: SetAttributeFilter(%s) failed.\n", pszWHERE );
 
370
            exit(1);
 
371
        }
 
372
    }
358
373
 
359
374
    if( poSpatialFilter != NULL )
360
375
        poLayer->SetSpatialFilter( poSpatialFilter );
364
379
/* -------------------------------------------------------------------- */
365
380
    printf( "\n" );
366
381
    
367
 
    printf( "Layer name: %s\n", poDefn->GetName() );
 
382
    printf( "Layer name: %s\n", poLayer->GetName() );
368
383
 
369
384
    if( bVerbose )
370
385
    {
371
386
        printf( "Geometry: %s\n", 
372
 
                OGRGeometryTypeToName( poDefn->GetGeomType() ) );
 
387
                OGRGeometryTypeToName( poLayer->GetGeomType() ) );
373
388
        
374
389
        printf( "Feature Count: %d\n", poLayer->GetFeatureCount() );
375
390