<DIV>Frank, this is my example for you to test the ver1.5.2 OGRFeatureStyle.cpp. Thank you.</DIV>
<DIV>//-------------------------------CODE----------------------------------------------------------</DIV>
<DIV> bool CreateDefaultStyle("shpcreate\\1.tbl", 2);</DIV>
<DIV> void main()<BR> {<BR> bool res = CreateDefaultStyle("shpcreate\\1.tbl", 2);<BR> }</DIV>
<DIV> </DIV>
<DIV>bool CreateDefaultStyle(CString strTlbPath, int nType)<BR>{ <BR> OGRStyleTable oStyleTable;<BR> OGRStyleMgr *poStyleMgr = new OGRStyleMgr(&oStyleTable);<BR> bool res;<BR> switch(nType)<BR> {<BR> case 1: //point<BR> {<BR> res = poStyleMgr->AddStyle("@symbol", "SYMBOL(c:#00FF00,id:\"swS0\",s:1.0,l:1)");<BR> res = poStyleMgr->AddStyle("@label", "LABEL(c:#FFFF00,f:\"MS Gothic\",s:10px,t:\"\",l:1)");<BR> res = oStyleTable.SaveStyleTable(strTlbPath);<BR> }<BR> break;<BR> case 2: //line<BR> {<BR> res = poStyleMgr->AddStyle("@symbol", "SYMBOL(c:#00FF00,id:\"swS0\",s:1.0,l:1)");//<BR> res = poStyleMgr->AddStyle("@label", "LABEL(c:#0000FF,f:\"MS Gothic\",s:10px,t:\"\",l:1)");//<BR> res = poStyleMgr->AddStyle("@line", "PEN(c:#FF0000,w:3px,id:\"swL0\",l:1)");//<BR> res = oStyleTable.SaveStyleTable(strTlbPath); <BR> }<BR> break;<BR> case 3: //polygon<BR> {<BR> res = poStyleMgr->AddStyle("@symbol", "SYMBOL(c:#00FF00,id:\"swS0\",s:1.0,l:1)");<BR> res = poStyleMgr->AddStyle("@label", "LABEL(c:#FF0000,f:\"MS Gothic\",s:10px,t:\"\",l:1)");<BR> res = poStyleMgr->AddStyle("@line", "PEN(c:#FF0000,w:3px,id:\"swL0\",l:1)");<BR> res = poStyleMgr->AddStyle("@brush", "BRUSH(fc:#C0C0C0,id:\"swR0\")");<BR> res = oStyleTable.SaveStyleTable(strTlbPath); <BR> }<BR> break;<BR> default:<BR> break;<BR> }<BR> if(poStyleMgr)<BR> {<BR> delete poStyleMgr;<BR> poStyleMgr = NULL;<BR> }<BR> if(!res)<BR> {<BR> return false;<BR> }<BR> return true;<BR>}</DIV>
<DIV>//--------------------------------END----------------------------------------------------------</DIV>
<DIV style="FONT-SIZE: 12px; COLOR: #909090; FONT-FAMILY: Arial Narrow">------------------</DIV>
<DIV>
<DIV>To the world you're little, but to a person you're the world.</DIV>
<DIV> Chen Xuexia</DIV></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 12px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px; FONT-FAMILY: Arial Narrow">------------------ Original ------------------</DIV>
<DIV style="FONT-SIZE: 12px">
<DIV id=menu_sender><B>From: </B> "wow"<27949218@qq.com>;</DIV>
<DIV><B>Date: </B> Tue, Aug 19, 2008 09:13 AM</DIV>
<DIV><B>To: </B> "Frank Warmerdam"<warmerdam@pobox.com>; </DIV>
<DIV><B>Cc: </B> "gdal-dev"<gdal-dev@lists.osgeo.org>; </DIV>
<DIV><B>Subject: </B> Re: [gdal-dev] OGRFeatureStyle update from version1.4.1 to 1.5.2;</DIV></DIV>
<DIV> </DIV>
<DIV style="FONT-WEIGHT: normal">
<DIV>Hi, Frank, welcome to China. I'd like to see you in Beijing, i'm sure that you're the joss of many young students, hehe.</DIV>
<DIV> I have found the reason why failed to deal styles with ver1.5.2. Compared with ver1.4.1, CPLSPrintf() is replaced the CPLString().Printf() , and i could trace the error to CPLString().Printf() every time debug. It might not allocate memory for the dest string in CPLString().Printf(). Of cource, if i still use CPLSPrintf(), no error occurs. Is this a bug in whole OGRFeatureStyle.cpp in ver1.5.2? </DIV>
<DIV style="FONT-SIZE: 12px; COLOR: #909090; FONT-FAMILY: Arial Narrow">------------------</DIV>
<DIV>
<DIV>To the world you're little, but to a person you're the world.</DIV>
<DIV> Chen Xuexia</DIV></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 12px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px; FONT-FAMILY: Arial Narrow">------------------ Original ------------------</DIV>
<DIV style="FONT-SIZE: 12px">
<DIV id=menu_sender><B>From: </B> "Frank Warmerdam"<warmerdam@pobox.com>;</DIV>
<DIV><B>Date: </B> Mon, Aug 18, 2008 11:12 PM</DIV>
<DIV><B>To: </B> "wow"<27949218@qq.com>; </DIV>
<DIV><B>Cc: </B> "gdal-dev"<gdal-dev@lists.osgeo.org>; </DIV>
<DIV><B>Subject: </B> Re: [gdal-dev] OGRFeatureStyle update from version1.4.1 to 1.5.2;</DIV></DIV>
<DIV> </DIV>
<DIV style="FONT-WEIGHT: normal">On 8/17/08, wow <27949218@qq.com> wrote:<BR>> Hi,<BR>> When i tried to update my whole program from ver1.4.1 to 1.5.2, all worked<BR>> well except the OGRFeatureStyle module. The function<BR>> OGRStyleMgr::AddStyle() couldn't write the provided style<BR>> name and style string right with ver1.5.2, but could run smoothly with<BR>> version 1.4.1.<BR>> My code :<BR><BR>Chen,<BR><BR>There has been some work on the style string parser since 1.4 and<BR>I suspect it has been subtly broken for your case in some fashion.<BR>Could you file a ticket? Make sure you provide any additional<BR>details we might need, like the format you are trying to write to.<BR><BR>Ideally a single small self contained program demonstrating the<BR>problem would be best.<BR><BR>Best regards,<BR>-- <BR>---------------------------------------+--------------------------------------<BR>I set the clouds in motion - turn up | Frank Warmerdam, warmerdam@pobox.com<BR>light and sound - activate the windows | http://pobox.com/~warmerdam<BR>and watch the world go round - Rush | Geospatial Programmer for Rent<BR></DIV></DIV>