<p dir="ltr">With Nik available for testing, I can update the style table definition.</p>
<div class="gmail_quote">On 3 Aug 2014 16:39, "Even Rouault" <<a href="mailto:even.rouault@mines-paris.org">even.rouault@mines-paris.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Le dimanche 03 août 2014 12:55:44, Nik Sands a écrit :<br>
> Thanks Even,<br>
><br>
> Yes, deleting the spaces seems to get it working correctly. Is this<br>
> expected? Are spaces an illegal part of a style string?<br>
><br>
> The documentation includes spaces in the example .ofs file there, so I had<br>
> copied that format when creating my text file.<br>
<br>
I guess we should be tolerant with spaces. The grammar of the style string<br>
itself seems to indicate that no spaces are expected in the style_def itself.<br>
But the format of the .ofs file is not really well defined.<br>
<br>
Perhaps Chaitanya will take care of that. See previous email.<br>
<br>
><br>
> Cheers,<br>
> Nik.<br>
><br>
> On 3 Aug 2014, at 8:45 pm, Even Rouault <<a href="mailto:even.rouault@mines-paris.org">even.rouault@mines-paris.org</a>><br>
wrote:<br>
> > Le dimanche 03 août 2014 12:41:56, Nik Sands a écrit :<br>
> >> Sorry, my mistake... I had my logging in the wrong place. styleChars is<br>
> >><br>
> >> actually of the form (including the leading space):<br>
> >> ' PEN(c:#A08080,w:2pt); LABEL(c:#000000,s:18pt,t:{title})'<br>
> ><br>
> > The issue must be the leading space before PEN, and potentially LABEL<br>
> > too.<br>
> ><br>
> >> On 3 Aug 2014, at 8:35 pm, Nik Sands <<a href="mailto:nixanz@nixanz.com">nixanz@nixanz.com</a>> wrote:<br>
> >>> On one of the iterations through this code, styleChars is:<br>
> >>> 'vegetation_low: BRUSH(fc:#A0F0A0); LABEL(c:#004000,s:18pt,t:<br>
{title})'<br>
> >>><br>
> >>> So perhaps the inclusion of the style name is the problem?<br>
> >>><br>
> >>> This was read into a style table from a text file using<br>
> >>> 'OGR_STBL_LoadStyleTable()'. I had assumed that a similar format to<br>
> >>> .ofs was suitable. If this is not the case, how should I read a style<br>
> >>> table from a text file in such a way that I can distinguish the various<br>
> >>> styles by name?<br>
> >>><br>
> >>> In guess my more general question is: What is the correct way to read<br>
> >>> styles from an arbitrary text file into a style table, and then use a<br>
> >>> style manager to get the various parts/tools?<br>
> >>><br>
> >>> On 3 Aug 2014, at 8:26 pm, Even Rouault <<a href="mailto:even.rouault@mines-paris.org">even.rouault@mines-paris.org</a>><br>
> ><br>
> > wrote:<br>
> >>>> Le dimanche 03 août 2014 12:11:42, Nik Sands a écrit :<br>
> >>>>> I'm just starting out using the styles features of OGR (using the C<br>
> >>>>> API) but at struggling with a few elements of it.<br>
> >>>>><br>
> >>>>> My code (copied below) fails to get any OGRStyleToolH. Ie, the "if (<br>
> >>>>> tool )" block never gets run, because 'tool' is always NULL at the<br>
> >>>>> point indicated by the comment. But the execution does reach that<br>
> >>>>> point in the code which indicates that the OGRStyleMrgH does in fact<br>
> >>>>> include at least one part (tool).<br>
> >>>>><br>
> >>>>> I'd be grateful if somebody could point out what I'm doing wrong.<br>
> >>>><br>
> >>>> Nothing strikes me as wrong. A potential explanation is that<br>
> >>>> styleChars doesn't contain a valid OGR Feature Style string.<br>
> >>>> GetPartCount() counts the number of ";" separating style parts, but it<br>
> >>>> doens't check that each style part actually begins by a recognized<br>
> >>>> tool name (PEN, BRUSH, SYMBOL, LABEL). OGR_SM_GetPart() does this<br>
> >>>> check however and if it cannot recognize it it returns a NULL tool.<br>
> >>>><br>
> >>>>> Thanks,<br>
> >>>>> Nik.<br>
> >>>>><br>
> >>>>><br>
> >>>>> -------------------------------------------<br>
> >>>>><br>
> >>>>> const char *styleChars = OGR_STBL_GetNextStyle(table) ) )<br>
> >>>>> NSString *styleName = [NSString<br>
> >>>>><br>
> >>>>> stringWithUTF8String:OGR_STBL_GetLastStyleName(table)]; OGRStyleMgrH<br>
> >>>>> styleMgr = OGR_SM_Create(NULL);<br>
> >>>>><br>
> >>>>> OGR_SM_InitStyleString(styleMgr, styleChars);<br>
> >>>>><br>
> >>>>><br>
> >>>>> for ( int i = 0; i < OGR_SM_GetPartCount(styleMgr, NULL); i++ )<br>
> >>>>> {<br>
> >>>>><br>
> >>>>> OGRStyleToolH tool = OGR_SM_GetPart(styleMgr, i, NULL);<br>
> >>>>><br>
> >>>>> if ( tool ) // 'tool' always NULL here<br>
> >>>>> {<br>
> >>>>><br>
> >>>>> switch ( OGR_ST_GetType(tool) )<br>
> >>>>> {<br>
> >>>>><br>
> >>>>> case OGRSTCPen:<br>
> >>>>> self.pen = tool;<br>
> >>>>> break;<br>
> >>>>><br>
> >>>>> case OGRSTCBrush:<br>
> >>>>> self.brush = tool;<br>
> >>>>> break;<br>
> >>>>><br>
> >>>>> case OGRSTCSymbol:<br>
> >>>>> self.symbol = tool;<br>
> >>>>> break;<br>
> >>>>><br>
> >>>>> case OGRSTCLabel:<br>
> >>>>> self.label = tool;<br>
> >>>>> break;<br>
> >>>>><br>
> >>>>> default:<br>
> >>>>> NSLog(@"Unknown style tool type!");<br>
> >>>>> break;<br>
> >>>>><br>
> >>>>> }<br>
> >>>>><br>
> >>>>> }<br>
> >>>>><br>
> >>>>> }<br>
> >>>>><br>
> >>>>> -------------------------------------------<br>
> >>>>><br>
> >>>>><br>
> >>>>> _______________________________________________<br>
> >>>>> gdal-dev mailing list<br>
> >>>>> <a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
> >>>>> <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
> >>><br>
> >>> _______________________________________________<br>
> >>> gdal-dev mailing list<br>
> >>> <a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
> >>> <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
<br>
--<br>
Geospatial professional services<br>
<a href="http://even.rouault.free.fr/services.html" target="_blank">http://even.rouault.free.fr/services.html</a><br>
</blockquote></div>