1841
1848
return(MS_FAILURE);
1851
/* -------------------------------------------------------------------- */
1852
/* Clear previously loaded shape. */
1853
/* -------------------------------------------------------------------- */
1855
shape->type = MS_SHAPE_NULL;
1857
/* -------------------------------------------------------------------- */
1858
/* Support reading feature by fid. */
1859
/* -------------------------------------------------------------------- */
1863
if( (hFeature = OGR_L_GetFeature( psInfo->hLayer, record )) == NULL )
1870
/* -------------------------------------------------------------------- */
1871
/* Support reading shape by offset within the current */
1873
/* -------------------------------------------------------------------- */
1874
else if( !record_is_fid )
1877
if( record <= psInfo->last_record_index_read
1878
|| psInfo->last_record_index_read == -1 )
1880
OGR_L_ResetReading( psInfo->hLayer );
1881
psInfo->last_record_index_read = -1;
1885
while( psInfo->last_record_index_read < record )
1887
if( hFeature != NULL )
1889
OGR_F_Destroy( hFeature );
1892
if( (hFeature = OGR_L_GetNextFeature( psInfo->hLayer )) == NULL )
1897
psInfo->last_record_index_read++;
1844
1901
/* ------------------------------------------------------------------
1845
1902
* Handle shape geometry...
1846
1903
* ------------------------------------------------------------------ */
1848
shape->type = MS_SHAPE_NULL;
1851
if( (hFeature = OGR_L_GetFeature( psInfo->hLayer, record )) == NULL )
1857
1904
// shape->type will be set if geom is compatible with layer type
1858
1905
if (ogrConvertGeometry(OGR_F_GetGeometryRef( hFeature ), shape,
1859
1906
layer->type) != MS_SUCCESS)
2509
2556
/**********************************************************************
2510
2557
* msOGRLayerGetShape()
2512
* Returns shape from OGR data source by id.
2559
* Returns shape from OGR data source by fid.
2514
2561
* Returns MS_SUCCESS/MS_FAILURE
2515
2562
**********************************************************************/
2516
2563
int msOGRLayerGetShape(layerObj *layer, shapeObj *shape, int tile,
2520
msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo;
2522
if (psInfo == NULL || psInfo->hLayer == NULL)
2524
msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!",
2525
"msOGRLayerNextShape()");
2529
if( layer->tileindex == NULL )
2530
return msOGRFileGetShape(layer, shape, record, psInfo );
2533
if( psInfo->poCurTile == NULL
2534
|| psInfo->poCurTile->nTileId != tile )
2536
if( msOGRFileReadTile( layer, psInfo, tile ) != MS_SUCCESS )
2540
return msOGRFileGetShape(layer, shape, record, psInfo->poCurTile );
2567
msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo;
2569
if (psInfo == NULL || psInfo->hLayer == NULL)
2571
msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!",
2572
"msOGRLayerNextShape()");
2576
if( layer->tileindex == NULL )
2577
return msOGRFileGetShape(layer, shape, fid, psInfo, TRUE );
2580
if( psInfo->poCurTile == NULL
2581
|| psInfo->poCurTile->nTileId != tile )
2583
if( msOGRFileReadTile( layer, psInfo, tile ) != MS_SUCCESS )
2587
return msOGRFileGetShape(layer, shape, fid, psInfo->poCurTile, TRUE );
2590
/* ------------------------------------------------------------------
2591
* OGR Support not included...
2592
* ------------------------------------------------------------------ */
2594
msSetError(MS_MISCERR, "OGR support is not available.",
2595
"msOGRLayerGetShape()");
2598
#endif /* USE_OGR */
2601
/**********************************************************************
2602
* msOGRLayerResultGetShape()
2604
* Returns shape from OGR data source by index into the current results
2607
* Returns MS_SUCCESS/MS_FAILURE
2608
**********************************************************************/
2609
int msOGRLayerResultGetShape(layerObj *layer, shapeObj *shape, int tile,
2613
msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo;
2615
if (psInfo == NULL || psInfo->hLayer == NULL)
2617
msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!",
2618
"msOGRLayerNextShape()");
2622
if( layer->tileindex == NULL )
2623
return msOGRFileGetShape(layer, shape, record, psInfo, FALSE );
2626
if( psInfo->poCurTile == NULL
2627
|| psInfo->poCurTile->nTileId != tile )
2629
if( msOGRFileReadTile( layer, psInfo, tile ) != MS_SUCCESS )
2633
return msOGRFileGetShape(layer, shape, record, psInfo->poCurTile, FALSE );
2543
2636
/* ------------------------------------------------------------------
2684
2777
* ------------------------------------------------------------------ */
2685
2778
ACQUIRE_OGR_LOCK;
2686
2779
if (psInfo->hLastFeature == NULL ||
2687
OGR_F_GetFID( psInfo->hLastFeature ) != record)
2780
psInfo->last_record_index_read != record)
2689
if (psInfo->hLastFeature)
2690
OGR_F_Destroy( psInfo->hLastFeature );
2692
psInfo->hLastFeature = OGR_L_GetFeature( psInfo->hLayer, record );
2783
msSetError(MS_MISCERR,
2784
"Assertion failed: AutoStyle not requested on loaded shape.",
2785
"msOGRLayerGetAutoStyle()");
2695
2789
/* ------------------------------------------------------------------