[gdal-dev] Usage of styles in C API

Nik Sands nixanz at nixanz.com
Sun Aug 3 03:11:42 PDT 2014


I'm just starting out using the styles features of OGR (using the C API) but at struggling with a few elements of it.

My code (copied below) fails to get any OGRStyleToolH.  Ie, the "if ( tool )" block never gets run, because 'tool' is always NULL at the point indicated by the comment.  But the execution does reach that point in the code which indicates that the OGRStyleMrgH does in fact include at least one part (tool).

I'd be grateful if somebody could point out what I'm doing wrong.

Thanks,
Nik.


-------------------------------------------
	const char *styleChars = OGR_STBL_GetNextStyle(table) ) )
	NSString *styleName = [NSString stringWithUTF8String:OGR_STBL_GetLastStyleName(table)];
	OGRStyleMgrH styleMgr = OGR_SM_Create(NULL);
	OGR_SM_InitStyleString(styleMgr, styleChars);


	for ( int i = 0; i < OGR_SM_GetPartCount(styleMgr, NULL); i++ )
	{
		OGRStyleToolH tool = OGR_SM_GetPart(styleMgr, i, NULL);
		
		if ( tool )  //  'tool' always NULL here
		{
			switch ( OGR_ST_GetType(tool) )
			{
				case OGRSTCPen:
					self.pen = tool;
					break;
					
				case OGRSTCBrush:
					self.brush = tool;
					break;
					
				case OGRSTCSymbol:
					self.symbol = tool;
					break;
					
				case OGRSTCLabel:
					self.label = tool;
					break;
					
				default:
					NSLog(@"Unknown style tool type!");
					break;
			}
		}
	}
-------------------------------------------




More information about the gdal-dev mailing list