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

Function msOGRGetValues

mapogr.cpp:555–1148  ·  view source on GitHub ↗

* msOGRGetValues() * * Load selected item (i.e. field) values into a char array * * Some special attribute names are used to return some OGRFeature params * like for instance stuff encoded in the OGRStyleString. * For now the following pseudo-attribute names are supported: * "OGR:TextString" OGRFeatureStyle's text string if present * "OGR:TextAngle" OGRFeatureStyle

Source from the content-addressed store, hash-verified

553 * "OGR:TextAngle" OGRFeatureStyle's text angle, or 0 if not set
554 **********************************************************************/
555static char **msOGRGetValues(layerObj *layer, OGRFeatureH hFeature)
556{
557 char **values;
558 const char *pszValue = NULL;
559 int i;
560
561 if(layer->numitems == 0)
562 return(NULL);
563
564 if(!layer->iteminfo) // Should not happen... but just in case!
565 if (msOGRLayerInitItemInfo(layer) != MS_SUCCESS)
566 return NULL;
567
568 if((values = (char **)malloc(sizeof(char *)*layer->numitems)) == NULL)
569 {
570 msSetError(MS_MEMERR, NULL, "msOGRGetValues()");
571 return(NULL);
572 }
573
574#if GDAL_VERSION_NUM >= 1500 /* Use OGR Style C API */
575 OGRStyleMgrH hStyleMgr = NULL;
576 OGRStyleToolH hLabelStyle = NULL;
577#else
578 OGRStyleMgr *poStyleMgr = NULL;
579 OGRStyleLabel *poLabelStyle = NULL;
580#endif
581 int *itemindexes = (int*)layer->iteminfo;
582
583 for(i=0;i<layer->numitems;i++)
584 {
585 if (itemindexes[i] >= 0)
586 {
587 // Extract regular attributes
588 values[i] = msStrdup(OGR_F_GetFieldAsString( hFeature, itemindexes[i]));
589 }
590 else
591#if GDAL_VERSION_NUM >= 1500 /* Use OGR Style C API */
592 {
593 // Handle special OGR attributes coming from StyleString
594 if (!hStyleMgr)
595 {
596 hStyleMgr = OGR_SM_Create(NULL);
597 OGR_SM_InitFromFeature(hStyleMgr, hFeature);
598 OGRStyleToolH hStylePart = OGR_SM_GetPart(hStyleMgr, 0, NULL);
599 if (hStylePart && OGR_ST_GetType(hStylePart) == OGRSTCLabel)
600 hLabelStyle = hStylePart;
601 else if (hStylePart)
602 {
603 OGR_ST_Destroy(hStylePart);
604 hStylePart = NULL;
605 }
606
607 /* Setting up the size units according to msOGRLayerGetAutoStyle*/
608 if (hStylePart && layer->map)
609 OGR_ST_SetUnit(hStylePart, OGRSTUPixel, layer->map->cellsize*72.0*39.37);
610 }
611 int bDefault;
612 if (itemindexes[i] == MSOGR_LABELTEXTINDEX)

Callers 2

msOGRFileNextShapeFunction · 0.85
msOGRFileGetShapeFunction · 0.85

Calls 4

msOGRLayerInitItemInfoFunction · 0.85
msSetErrorFunction · 0.85
msStrdupFunction · 0.85
msDebugFunction · 0.85

Tested by

no test coverage detected