MCPcopy Index your code
hub / github.com/MapServer/MapServer / msOGRFileGetShape

Function msOGRFileGetShape

mapogr.cpp:1942–2061  ·  view source on GitHub ↗

* msOGRFileGetShape() * * Returns shape from OGR data source by id. * * Returns MS_SUCCESS/MS_FAILURE **********************************************************************/

Source from the content-addressed store, hash-verified

1940 * Returns MS_SUCCESS/MS_FAILURE
1941 **********************************************************************/
1942static int
1943msOGRFileGetShape(layerObj *layer, shapeObj *shape, long record,
1944 msOGRFileInfo *psInfo, int record_is_fid )
1945{
1946 OGRFeatureH hFeature;
1947
1948 if (psInfo == NULL || psInfo->hLayer == NULL)
1949 {
1950 msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!",
1951 "msOGRFileNextShape()");
1952 return(MS_FAILURE);
1953 }
1954
1955/* -------------------------------------------------------------------- */
1956/* Clear previously loaded shape. */
1957/* -------------------------------------------------------------------- */
1958 msFreeShape(shape);
1959 shape->type = MS_SHAPE_NULL;
1960
1961/* -------------------------------------------------------------------- */
1962/* Support reading feature by fid. */
1963/* -------------------------------------------------------------------- */
1964 if( record_is_fid )
1965 {
1966 ACQUIRE_OGR_LOCK;
1967 if( (hFeature = OGR_L_GetFeature( psInfo->hLayer, record )) == NULL )
1968 {
1969 RELEASE_OGR_LOCK;
1970 return MS_FAILURE;
1971 }
1972 }
1973
1974/* -------------------------------------------------------------------- */
1975/* Support reading shape by offset within the current */
1976/* resultset. */
1977/* -------------------------------------------------------------------- */
1978 else if( !record_is_fid )
1979 {
1980 ACQUIRE_OGR_LOCK;
1981 if( record <= psInfo->last_record_index_read
1982 || psInfo->last_record_index_read == -1 )
1983 {
1984 OGR_L_ResetReading( psInfo->hLayer );
1985 psInfo->last_record_index_read = -1;
1986 }
1987
1988 hFeature = NULL;
1989 while( psInfo->last_record_index_read < record )
1990 {
1991 if( hFeature != NULL )
1992 {
1993 OGR_F_Destroy( hFeature );
1994 hFeature = NULL;
1995 }
1996 if( (hFeature = OGR_L_GetNextFeature( psInfo->hLayer )) == NULL )
1997 {
1998 RELEASE_OGR_LOCK;
1999 return MS_FAILURE;

Callers 1

msOGRLayerGetShapeFunction · 0.85

Calls 4

msSetErrorFunction · 0.85
msFreeShapeFunction · 0.85
ogrConvertGeometryFunction · 0.85
msOGRGetValuesFunction · 0.85

Tested by

no test coverage detected