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

Function msOGRLayerGetAutoStyle

mapogr.cpp:3542–3619  ·  view source on GitHub ↗

* msOGRLayerGetAutoStyle() * * Fills a classObj with style info from the specified shape. * For optimal results, this should be called immediately after * GetNextShape() or GetShape() so that the shape doesn't have to be read * twice. * * The returned classObj is a ref. to a static structure valid only until * the next call and that shouldn't be freed by the caller. *

Source from the content-addressed store, hash-verified

3540 * the next call and that shouldn't be freed by the caller.
3541 **********************************************************************/
3542static int msOGRLayerGetAutoStyle(mapObj *map, layerObj *layer, classObj *c,
3543 shapeObj* shape)
3544{
3545#ifdef USE_OGR
3546 msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo;
3547
3548 if (psInfo == NULL || psInfo->hLayer == NULL)
3549 {
3550 msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!",
3551 "msOGRLayerGetAutoStyle()");
3552 return(MS_FAILURE);
3553 }
3554
3555 if( layer->tileindex != NULL )
3556 {
3557 if( (psInfo->poCurTile == NULL || shape->tileindex != psInfo->poCurTile->nTileId)
3558 && msOGRFileReadTile( layer, psInfo ) != MS_SUCCESS )
3559 return MS_FAILURE;
3560
3561 psInfo = psInfo->poCurTile;
3562 }
3563
3564/* ------------------------------------------------------------------
3565 * Read shape or reuse ref. to last shape read.
3566 * ------------------------------------------------------------------ */
3567 ACQUIRE_OGR_LOCK;
3568 if (psInfo->hLastFeature == NULL ||
3569 psInfo->last_record_index_read != shape->resultindex)
3570 {
3571 RELEASE_OGR_LOCK;
3572 msSetError(MS_MISCERR,
3573 "Assertion failed: AutoStyle not requested on loaded shape.",
3574 "msOGRLayerGetAutoStyle()");
3575 return(MS_FAILURE);
3576 }
3577
3578/* ------------------------------------------------------------------
3579 * Reset style info in the class to defaults
3580 * the only members we don't touch are name, expression, and join/query stuff
3581 * ------------------------------------------------------------------ */
3582 resetClassStyle(c);
3583 if (msMaybeAllocateClassStyle(c, 0)) {
3584 RELEASE_OGR_LOCK;
3585 return(MS_FAILURE);
3586 }
3587
3588 // __TODO__ label cache incompatible with styleitem feature.
3589 layer->labelcache = MS_OFF;
3590
3591 int nRetVal = MS_SUCCESS;
3592 if (psInfo->hLastFeature)
3593 {
3594#if GDAL_VERSION_NUM >= 1500 /* Use OGR Style C API */
3595 OGRStyleMgrH hStyleMgr = OGR_SM_Create(NULL);
3596 OGR_SM_InitFromFeature(hStyleMgr, psInfo->hLastFeature);
3597 nRetVal = msOGRUpdateStyle(hStyleMgr, map, layer, c);
3598 OGR_SM_Destroy(hStyleMgr);
3599#else /* OGRStyle C++ */

Callers

nothing calls this directly

Calls 5

msSetErrorFunction · 0.85
msOGRFileReadTileFunction · 0.85
resetClassStyleFunction · 0.85
msOGRUpdateStyleFunction · 0.85

Tested by

no test coverage detected