* msOGRFileNextShape() * * Returns shape sequentially from OGR data source. * msOGRLayerWhichShape() must have been called first. * * Returns MS_SUCCESS/MS_FAILURE **********************************************************************/
| 1822 | * Returns MS_SUCCESS/MS_FAILURE |
| 1823 | **********************************************************************/ |
| 1824 | static int |
| 1825 | msOGRFileNextShape(layerObj *layer, shapeObj *shape, |
| 1826 | msOGRFileInfo *psInfo ) |
| 1827 | { |
| 1828 | OGRFeatureH hFeature = NULL; |
| 1829 | |
| 1830 | if (psInfo == NULL || psInfo->hLayer == NULL) |
| 1831 | { |
| 1832 | msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", |
| 1833 | "msOGRFileNextShape()"); |
| 1834 | return(MS_FAILURE); |
| 1835 | } |
| 1836 | |
| 1837 | /* ------------------------------------------------------------------ |
| 1838 | * Read until we find a feature that matches attribute filter and |
| 1839 | * whose geometry is compatible with current layer type. |
| 1840 | * ------------------------------------------------------------------ */ |
| 1841 | msFreeShape(shape); |
| 1842 | shape->type = MS_SHAPE_NULL; |
| 1843 | |
| 1844 | ACQUIRE_OGR_LOCK; |
| 1845 | while (shape->type == MS_SHAPE_NULL) |
| 1846 | { |
| 1847 | if( hFeature ) |
| 1848 | OGR_F_Destroy( hFeature ); |
| 1849 | |
| 1850 | if( (hFeature = OGR_L_GetNextFeature( psInfo->hLayer )) == NULL ) |
| 1851 | { |
| 1852 | psInfo->last_record_index_read = -1; |
| 1853 | if( CPLGetLastErrorType() == CE_Failure ) |
| 1854 | { |
| 1855 | msSetError(MS_OGRERR, "%s", "msOGRFileNextShape()", |
| 1856 | CPLGetLastErrorMsg() ); |
| 1857 | RELEASE_OGR_LOCK; |
| 1858 | return MS_FAILURE; |
| 1859 | } |
| 1860 | else |
| 1861 | { |
| 1862 | RELEASE_OGR_LOCK; |
| 1863 | if (layer->debug >= MS_DEBUGLEVEL_VV) |
| 1864 | msDebug("msOGRFileNextShape: Returning MS_DONE (no more shapes)\n" ); |
| 1865 | return MS_DONE; // No more features to read |
| 1866 | } |
| 1867 | } |
| 1868 | |
| 1869 | psInfo->last_record_index_read++; |
| 1870 | |
| 1871 | if(layer->numitems > 0) |
| 1872 | { |
| 1873 | shape->values = msOGRGetValues(layer, hFeature); |
| 1874 | shape->numvalues = layer->numitems; |
| 1875 | if(!shape->values) |
| 1876 | { |
| 1877 | OGR_F_Destroy( hFeature ); |
| 1878 | RELEASE_OGR_LOCK; |
| 1879 | return(MS_FAILURE); |
| 1880 | } |
| 1881 | } |
no test coverage detected