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

Function msOGRLayerOpen

mapogr.cpp:2201–2307  ·  view source on GitHub ↗

* msOGRLayerOpen() * * Open OGR data source for the specified map layer. * * If pszOverrideConnection != NULL then this value is used as the connection * string instead of lp->connection. This is used for instance to open * a WFS layer, in this case lp->connection is the WFS url, but we want * OGR to open the local file on disk that was previously downloaded. * * An O

Source from the content-addressed store, hash-verified

2199 * Returns MS_SUCCESS/MS_FAILURE
2200 **********************************************************************/
2201int msOGRLayerOpen(layerObj *layer, const char *pszOverrideConnection)
2202{
2203#ifdef USE_OGR
2204
2205 msOGRFileInfo *psInfo;
2206
2207 if (layer->layerinfo != NULL)
2208 {
2209 return MS_SUCCESS; // Nothing to do... layer is already opened
2210 }
2211
2212/* -------------------------------------------------------------------- */
2213/* If this is not a tiled layer, just directly open the target. */
2214/* -------------------------------------------------------------------- */
2215 if( layer->tileindex == NULL )
2216 {
2217 psInfo = msOGRFileOpen( layer,
2218 (pszOverrideConnection ? pszOverrideConnection:
2219 layer->connection) );
2220 layer->layerinfo = psInfo;
2221 layer->tileitemindex = -1;
2222
2223 if( layer->layerinfo == NULL )
2224 return MS_FAILURE;
2225 }
2226
2227/* -------------------------------------------------------------------- */
2228/* Otherwise we open the tile index, identify the tile item */
2229/* index and try to select the first file matching our query */
2230/* region. */
2231/* -------------------------------------------------------------------- */
2232 else
2233 {
2234 // Open tile index
2235
2236 psInfo = msOGRFileOpen( layer, layer->tileindex );
2237 layer->layerinfo = psInfo;
2238
2239 if( layer->layerinfo == NULL )
2240 return MS_FAILURE;
2241
2242 // Identify TILEITEM
2243
2244 OGRFeatureDefnH hDefn = OGR_L_GetLayerDefn( psInfo->hLayer );
2245 for( layer->tileitemindex = 0;
2246 layer->tileitemindex < OGR_FD_GetFieldCount( hDefn )
2247 && !EQUAL( OGR_Fld_GetNameRef( OGR_FD_GetFieldDefn( hDefn, layer->tileitemindex) ),
2248 layer->tileitem);
2249 layer->tileitemindex++ ) {}
2250
2251 if( layer->tileitemindex == OGR_FD_GetFieldCount( hDefn ) )
2252 {
2253 msSetError(MS_OGRERR,
2254 "Can't identify TILEITEM %s field in TILEINDEX `%s'.",
2255 "msOGRLayerOpen()",
2256 layer->tileitem, layer->tileindex );
2257 msOGRFileClose( layer, psInfo );
2258 layer->layerinfo = NULL;

Callers 2

msOGRLayerOpenVTFunction · 0.85
msWFSLayerWhichShapesFunction · 0.85

Calls 5

msOGRFileOpenFunction · 0.85
msSetErrorFunction · 0.85
msOGRFileCloseFunction · 0.85
msGetErrorObjFunction · 0.85

Tested by

no test coverage detected