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

« back to all changes in this revision

Viewing changes to ogr/ogrsf_frmts/ogdi/ogrogdilayer.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: ogrogdilayer.cpp 18502 2010-01-09 19:38:29Z rouault $
 
2
 * $Id: ogrogdilayer.cpp 23014 2011-08-31 18:40:35Z rouault $
3
3
 *
4
4
 * Project:  OGDI Bridge
5
5
 * Purpose:  Implements OGROGDILayer class.
56
56
#include "cpl_conv.h"
57
57
#include "cpl_string.h"
58
58
 
59
 
CPL_CVSID("$Id: ogrogdilayer.cpp 18502 2010-01-09 19:38:29Z rouault $");
 
59
CPL_CVSID("$Id: ogrogdilayer.cpp 23014 2011-08-31 18:40:35Z rouault $");
60
60
 
61
61
/************************************************************************/
62
62
/*                           OGROGDILayer()                            */
125
125
}
126
126
 
127
127
/************************************************************************/
 
128
/*                         SetAttributeFilter()                         */
 
129
/************************************************************************/
 
130
 
 
131
OGRErr OGROGDILayer::SetAttributeFilter( const char *pszQuery )
 
132
{
 
133
    OGRErr eErr = OGRLayer::SetAttributeFilter(pszQuery);
 
134
 
 
135
    ResetReading();
 
136
 
 
137
    m_nTotalShapeCount = -1;
 
138
 
 
139
    return eErr;
 
140
}
 
141
 
 
142
/************************************************************************/
128
143
/*                            ResetReading()                            */
129
144
/************************************************************************/
130
145
 
179
194
    }
180
195
 
181
196
    m_iNextShapeId = 0;
 
197
    m_nFilteredOutShapes = 0;
182
198
}
183
199
 
184
200
/************************************************************************/
208
224
    if (! ECSSUCCESS(psResult))
209
225
    {
210
226
        // We probably reached EOF... keep track of shape count.
211
 
        m_nTotalShapeCount = m_iNextShapeId;
 
227
        m_nTotalShapeCount = m_iNextShapeId - m_nFilteredOutShapes;
212
228
        return NULL;
213
229
    }
214
230
   
225
241
        ecs_Point       *psPoint = &(ECSGEOM(psResult).point);
226
242
        OGRPoint        *poOGRPoint = new OGRPoint(psPoint->c.x, psPoint->c.y);
227
243
 
 
244
        poOGRPoint->assignSpatialReference(m_poSpatialRef);
228
245
        poFeature->SetGeometryDirectly(poOGRPoint);
229
246
    }
230
247
    else if (m_eFamily == Line)
239
256
            poOGRLine->setPoint(i, psLine->c.c_val[i].x, psLine->c.c_val[i].y);
240
257
        }
241
258
 
 
259
        poOGRLine->assignSpatialReference(m_poSpatialRef);
242
260
        poFeature->SetGeometryDirectly(poOGRLine);
243
261
    }
244
262
    else if (m_eFamily == Area)
264
282
        // __TODO__
265
283
        // When OGR supports polygon centroids then we should carry them here
266
284
 
 
285
        poOGRPolygon->assignSpatialReference(m_poSpatialRef);
267
286
        poFeature->SetGeometryDirectly(poOGRPolygon);
268
287
    }
269
288
    else if (m_eFamily == Text)
274
293
        ecs_Text       *psText = &(ECSGEOM(psResult).text);
275
294
        OGRPoint        *poOGRPoint = new OGRPoint(psText->c.x, psText->c.y);
276
295
 
 
296
        poOGRPoint->assignSpatialReference(m_poSpatialRef);
277
297
        poFeature->SetGeometryDirectly(poOGRPoint);
278
298
    }
279
299
    else
341
361
        || (m_poFilterGeom != NULL 
342
362
            && !FilterGeometry( poFeature->GetGeometryRef() ) ) )
343
363
    {
 
364
        m_nFilteredOutShapes ++;
344
365
        delete poFeature;
345
366
        goto TryAgain;
346
367
    }
360
381
    if (m_nTotalShapeCount != -1 && nFeatureId > m_nTotalShapeCount)
361
382
        return NULL;
362
383
 
363
 
    if (m_iNextShapeId > nFeatureId )
 
384
    /* Reset reading if we are not the current layer */
 
385
    /* WARNING : this does not allow interleaved reading of layers */
 
386
    if( m_poODS->GetCurrentLayer() != this )
 
387
    {
 
388
        m_poODS->SetCurrentLayer(this);
 
389
        ResetReading();
 
390
    }
 
391
    else if ( nFeatureId < m_iNextShapeId )
364
392
        ResetReading();
365
393
 
366
394
    while(m_iNextShapeId != nFeatureId)
413
441
/*      For now just return FALSE for everything.                       */
414
442
/* -------------------------------------------------------------------- */
415
443
#ifdef __TODO__
416
 
    if( EQUAL(pszCap,OLCRandomRead) )
417
 
        return TRUE;
418
 
 
419
 
    else if( EQUAL(pszCap,OLCFastFeatureCount) )
420
 
        return m_poFilterGeom == NULL;
 
444
    if( EQUAL(pszCap,OLCFastFeatureCount) )
 
445
        return m_poFilterGeom == NULL && m_poAttrQuery == NULL;
421
446
 
422
447
    else if( EQUAL(pszCap,OLCFastSpatialFilter) )
423
448
        return FALSE;
426
451
        return FALSE;
427
452
#endif
428
453
 
429
 
    return FALSE;
 
454
    if( EQUAL(pszCap,OLCRandomRead) )
 
455
        return TRUE;
 
456
 
 
457
    else
 
458
        return FALSE;
430
459
}
431
460
 
432
461
 
472
501
        eLayerGeomType = wkbUnknown;
473
502
        break;
474
503
    }
475
 
 
476
 
    m_poFeatureDefn = new OGRFeatureDefn(CPLSPrintf("%s_%s", 
 
504
    
 
505
    char* pszFeatureDefnName;
 
506
    if (m_poODS->LaunderLayerNames())
 
507
    {
 
508
        pszFeatureDefnName = CPLStrdup(m_pszOGDILayerName);
 
509
        char* pszAt = strchr(pszFeatureDefnName, '@');
 
510
        if (pszAt)
 
511
            *pszAt = '_';
 
512
        char* pszLeftParenthesis = strchr(pszFeatureDefnName, '(');
 
513
        if (pszLeftParenthesis)
 
514
            *pszLeftParenthesis = '\0';
 
515
    }
 
516
    else
 
517
        pszFeatureDefnName = CPLStrdup(CPLSPrintf("%s_%s", 
477
518
                                                    m_pszOGDILayerName, 
478
519
                                                    pszGeomName ));
 
520
 
 
521
    m_poFeatureDefn = new OGRFeatureDefn(pszFeatureDefnName);
 
522
    CPLFree(pszFeatureDefnName);
 
523
    pszFeatureDefnName = NULL;
 
524
    
479
525
    m_poFeatureDefn->SetGeomType(eLayerGeomType);
480
526
    m_poFeatureDefn->Reference();
481
527