[gdal-dev] OGRStyleTool::GetStyleString() loosing quotes after modification
Andre Vautour
andre.vautour at caris.com
Thu Sep 4 13:07:46 PDT 2014
I ran into a problem where a quoted text string in a OGR Style String
gets lost while interacting with it via an OGRStyleTool. Using the same
style string afterwords causes OGRStyleTool::Parse() to fail because the
quote string contained parentheses which would have typically been
ignored because of the CSLT_HONOURSTRINGS and CSLT_PRESERVEQUOTES flags
that are passed to CSLTokenizeString2.
Here is a code snippet that exposes the issue that I am seeing:
void testGetStyleString()
{
const char* const originalStyleString = "LABEL(t:\"MyText(1)\")";
std::cout << "originalStyleString:" << originalStyleString <<
std::endl;
::OGRStyleLabel styleLabel;
styleLabel.SetStyleString(originalStyleString);
const char* const styleStringAfterBeingSet =
styleLabel.GetStyleString();
std::cout << "styleStringAfterBeingSet:" <<
styleStringAfterBeingSet << std::endl;
GBool defaultValue = false;
const char* const textString = styleLabel.TextString(defaultValue);
std::cout << "textString:" << textString << std::endl;
const char* const styleStringAfterParsingStage =
styleLabel.GetStyleString();
std::cout << "styleStringAfterParsingStage:" <<
styleStringAfterParsingStage << std::endl;
return;
}
Which produces the following output:
originalStyleString:LABEL(t:"MyText(1)")
styleStringAfterBeingSet:LABEL(t:"MyText(1)")
textString:MyText(1)
styleStringAfterParsingStage:LABEL(t:MyText(1))
So, the main problem I have encountered, as far as I can tell is that
GetStyleString() does not honor the quotes after it has been set to have
been parse and set as modified (StyleModified). I my case, I didn't even
modify the tool, OGRStyleTool::Parse() seems to be the one who set the
style tool as being modified. The modified flag is why GetStyleString()
regenerates the string from the parameters. So, I have two questions:
1. Should Parse() set the style tool as modified as it currently does?
2. Should the parsing of the parameters retain the quotes? It currently
doesn't specify CSLT_PRESERVEQUOTES when splitting t:"MyText" at the colon.
Doing #2 would obviously mean the TextString() would return the quoted
string which it doesn't do currently.
Any thoughts?
André
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20140904/9cf47dc2/attachment.html>
More information about the gdal-dev
mailing list