This does not prevent us from storing the style information in an attribute when writing to some formats that have no provision for styles (e.g. E00). But then at the time such a dataset is opened through OGR, the name of the attribute that contains style information should either be specified in some metadata, or be specified by the user.
Also, in the SFCOM interface, the style information will be stored in an attribute just like the geometry is. Later in this document, we will define a kind of "WKT" format to be used when storing style information in text form.
There are actually 2 levels at which style information can be found:
However, all that stuff should be transparent to the OGR client that does not want to worry about the details and a single call to a method such as OGRFeature::GetStyleString() should hide all the magic and always return the right information.
A style can use a single tool, or use a combination of one or more tools. By combining the use of several tools in a style, one can build virtually any type of graphical representation. For instance, the SYMBOL tool can be used to place spaced symbols along a line. Also, the LABEL tool can be used to place text on a point, stretch it along a line, or even, by combining the PEN tool with the LABEL tool, use the line as a leader to the text label, and draw the text string on the last vertex of the line.
Of course only few systems can support all that. But the intention here is to have a style specification that is powerful and flexible enough to allow all types of formats to exchange style information with the least possible loss.
Example of this are text angle, text string, etc... these values change for every single text label, but we can share the rest of the label style at the layer level if we lookup the angle and text string in an attribute on each feature.
The syntax of the style string provides a way that any parameter value can be either a constant value, or a lookup to an attribute field.
Here we go with some style definition strings:
A 5 pixels wide red line: "PEN(c:#FF0000,w:5px)" A polygon filled in blue, with a black outline: "BRUSH(fc:#0000FF);PEN(c:#000000)" A point symbol: "SYMBOL(c:#00FF00,id:"points.sym-45,ogr-sym-7")" A text label, taking the text string from the "text_string" attribute field: "LABEL(f:"Times New Roman",s:12pt,t:{text_string})"Here is what a style table that contains all the above styles could look like:
road: PEN(c:#FF0000,w:5px) lake: BRUSH(fc:#0000FF);LINE(c:#000000) campsite: SYMBOL(c:#00FF00,id:"points.sym-45,ogr-sym-7") label: LABEL(f:"Times New Roman",s:12pt,t:{text_string})And then individual features could refer to styles from the table above using the "@" character followed by the style name in their style property.
For instance, a feature with its style set to "@road" would be drawn as a red line.
<style_property> = "<style_def>" | "" | "@<style_name>" | "{<field_name>}" |
<style_def> = <style_part>[;<style_part>[;...]] <style_part> = <tool_name>([<tool_param>[,<tool_param>[,...]]]) <tool_name> = name of a drawing tool, for now: PEN | BRUSH | SYMBOL | LABEL <tool_param> = <param_name>:<param_value> <param_name> = see list of parameters names for each drawing tool <param_value> = <value> | <value><units> <value> = "<string_value>" | <numeric_value> | {<field_name>} <units> = g | px | pt | mm | cm | in |
By default, style parts are drawn in the order that they appear in the style_def string unless each part is assigned a different level parameter value (see the level parameter definition).
All drawing tool parameters are optional. So it is legal to have a style_part with an empty drawing tool parameter list (e.g. "PEN()"). For each parameter that does not have any specified value, it is up to the client application to use its own default value. This document provides advisory default values for most parameters, but it is not mandatory for an application to use those default value.
When {<field_name>} is used for a tool_param value, several options are available with respect to the units. The units can be specified after the field name as in PEN(c:#FF0000,w:{line_width}pt) or can be left unspecified as in PEN(c:#FF0000,w:{line_width}). In the first case, the default units will be points (pt), but if the attribute field line_width contains a value followed by a units abbreviation (e.g. "5px") then the units specified in the attribute fields have precedence (in this case pixels). Note that the attribute field does not have to contain a units value and probably won't in most cases, it is just an optional feature to be able to override the default units from inside an attribute field's value.
param_name | Description |
---|---|
c | Pen Color, expressed in hexadecimal (#RRGGBB[AA])
[AA] the last 2 digits define the alpha channel value, with 0 being transparent and FF being opaque. The default is FF (opaque) Suggested default: black (c:#000000) Example: PEN(c:#FF0000), or PEN(C:#FF0000FF) Predefined color names may be allowed in future versions of the specification. |
w | Pen Width - Expressed in a valid unit type (g, px, pt, mm, cm,
in)
Suggested default: 1 pixel Examples: PEN(c:#FF0000,w:5px), PEN(w:3pt), PEN(w:50g) |
p | Pattern - To create dash lines. A list of pen-down/pen-up distances
Examples: = PEN(c:#FF0000,w:2px,p:"4px 5px") - short-dash line = PEN(c:#FF0000,w:2px,p:"10px 5px") - long-dash line = PEN(c:#FF0000,w:2px,p:"10px 5px 4px 5px") - long/short dash line |
id | Comma-delimited list of Pen Names or Ids - For systems that
identify pens with a name or an id. The names in the comma-delimited list
of ids are scanned until one is recognized by the target system.
Pen Ids can be either system-specific ids (see further below) or be one of the pre-defined OGR pen ids for well known line patterns. The id parameter should always include one of the OGR ids at the end of the comma-delimited list of ids so that an application never has to rely on understanding system-specific ids.
Here is the current list of OGR pen ids (this could grow over time):
System-specific ids are very
likely to be meaningful only to that specific system that created them.
The ids should start with the system's name, followed by a dash (-),
followed by whatever information is meaningful to that system (a number,
a name, a filename, etc.). System-specific ids are allowed in order to prevent loss of information when dealing with data from systems that store line patterns in external files or that have their own pre-defined set of line styles. (To do a MapInfo MIF to TAB translation without any loss for instance.) Examples: |
cap | Pen Cap - Set the shape of end points of lines. b=BUTT The ends of the line don't extend beyond the end points. This is the default. r=ROUND Terminate lines with a circle whose diameter is equal to the line width. p=PROJECTING Similar to BUTT, but the ends of the line extend by half of line width beyond the end points. |
j | Pen Join - Set the shape of the join point (vertex) of lines. m=MITER Extend the outer edge of the lines until they touch. This is the default. r=ROUNDED Join lines with an arc whose center is at the join point and whose diameter is equal to the line width. b=BEVEL Join the lines with butt end caps and fill the resulting triangular notch at the join position. |
dp | Perpendicular Offset - Offset from the line center If the offset is negative then the pen will be drawn left of the main segment and right otherwise. |
l | Priority Level - Numeric value defining the order in which style
parts should be drawn. Lower priority style parts are drawn first, and
higher priority ones are drawn on top.
If priority level is unspecified, the default is 1. |
param_name | Description |
---|---|
fc |
Brush ForeColor, expressed in hexadecimal (#RRGGBB[AA])
|
bc |
Brush BackColor, expressed in hexadecimal (#RRGGBB[AA])
|
id |
Brush Name or Brush Id - Comma-delimited list of brush names or ids. The names in the comma-delimited list of ids are scanned until one is recognized by the target system. Brush Ids can be either system-specific ids (see further below) or be one of the pre-defined OGR brush ids for well known brush patterns. The id parameter should always include one of the OGR ids at the end of the comma-delimited list of ids so that an application never has to rely on understanding system-specific ids.
Here is the current list of OGR brush ids (this could grow over time):
Like with Pen Ids, system-specific brush ids are very likely to be meaningful only to that specific system that created them. The ids should start with the system's name, followed by a dash (-), followed by whatever information is meaningful to that system (a number, a name, a filename, etc.). The following conventions will be used for common system-specific brush ids:
|
a | Angle - Rotation angle (in degrees, counterclockwise) to apply to the brush pattern. |
s | Size or Scaling Factor - Numeric value with or without units.
If units are specified, then this value is the absolute size to draw the brush or symbol. If no units are specified then it is taken as a scaling factor relative to the symbol's default size. |
dx, dy | Spacing - If filling an area using point symbols, these values
will define the spacing to use between them. "dx" is the horizontal distance
between the center of 2 adjacent symbols and "dy" is the vertical distance.
The default is to use the symbol's MBR width for dx, and the symbol's height for dy. |
l | Priority Level - Numeric value defining the order in which style
parts should be drawn. Lower priority style parts are drawn first, and
higher priority ones are drawn on top.
If priority level is unspecified, the default is 1. |
param_name | Description |
---|---|
id |
Symbol Name or Id - Comma-delimited list of symbol names or ids. The names in the comma-delimited list of ids are scanned until one is recognized by the target system. Symbol Ids can be either system-specific ids (see further below) or be one of the pre-defined OGR symbol ids for well known symbols. The id parameter should always include one of the OGR ids at the end of the comma-delimited list of ids so that an application never has to rely on understanding system-specific ids.
Here is the current list of OGR symbol ids (this could grow over time):
Like with Pen Ids, system-specific symbol ids are very likely to be meaningful only to that specific system that created them. The ids should start with the system's name, followed by a dash (-), followed by whatever information is meaningful to that system (a number, a name, a filename, etc.). The following conventions will be used for common system-specific symbol ids:
|
a | Angle - Rotation angle (in degrees, counterclockwise) to apply to the symbol. |
c |
Symbol Color, expressed in hexadecimal (#RRGGBB[AA])
|
o |
Symbol Outline Color, expressed in hexadecimal (#RRGGBB[AA]), no outline if not set. |
s | Size or Scaling Factor - Numeric value with or without units.
If units are specified, then this value is the absolute size to draw the symbol. If no units are specified then it is taken as a scaling factor relative to the symbol's default size. |
dx, dy | X and Y offset of the symbol's insertion point.
Applies to point geometries, and to symbols placed at each vertex of a polyline. |
ds, dp, di | Spacing - For symbols spaced along a line.
"ds" is the step to use when placing symbols along the line. By default, symbols applied to a feature with a line geometry are placed at each vertex, but setting "ds" triggers the placement of symbols at an equal distance along the line. "ds" has no effect for a feature with a point geometry. "dp" can be used together with "ds" to specify the perpendicular distance between the symbols' center and the line along which they're placed. Finally, "di" can be used to specify an initial offset from the beginning of the line. Example: SYMBOL(id:123, s:5, di:5px, ds:50px) |
l | Priority Level - Numeric value defining the order in which style
parts should be drawn. Lower priority style parts are drawn first, and
higher priority ones are drawn on top.
If priority level is unspecified, the default is 1. |
param_name | Description | ||
---|---|---|---|
f | Font Name -
Comma-delimited list of fonts names. works like the HTML FONT tag: the list of font names is scanned until a supported font name is encountered. Example: LABEL(f:"Arial, Helvetica", s:12pt, t:"Hello World!") |
||
s | Font Size - Numeric value with units. | ||
t | Text String - Can be a constant string, or a reference to an
attribute field's value.
Examples: LABEL(f:"Arial, Helvetica", s:12pt, t:"Hello World!") LABEL(f:"Arial, Helvetica", s:12pt, t:{text_value}) |
||
a | Angle - Rotation angle (in degrees, counterclockwise). | ||
c | Text Foreground Color, expressed in hexadecimal (#RRGGBB[AA])
Suggested default: black (c:#000000) Predefined color names may be allowed in future versions of the specification. |
||
b | Text Background Color - Color of the filled box to draw behind the label, expressed in hexadecimal (#RRGGBB[AA]), no box drawn if not set. | ||
o | Text Outline Color - Color of the text outline (halo in MapInfo terminology), expressed in hexadecimal (#RRGGBB[AA]), no outline if not set. | ||
h | Shadow Color - Color of the text shadow, expressed in hexadecimal (#RRGGBB[AA]), no shadow if not set. | ||
w | Stretch - The stretch factor changes the width of all characters in the font by factor percent. For example, setting factor to 150 results in all characters in the font being 1.5 times (i.e. 150%) wider. The default stretch factor is 100. | ||
st | Strike out text | ||
m | Label Placement Mode - How is the text drawn relative to the
feature's geometry.
"m:p" - The default, simple label attached to a point or to the first vertex of a polyline. "m:l" - Text is attached to the last vertex of a polyline. A PEN tool can be combined with this LABEL tool to draw the polyline as a leader to the label. "m:s" - Stretch text string along polyline, with an equal spacing between each character. "m:m" - Place text as a single label at the middle of a polyline (based on total line length). "m:w" - One word per line segment in a polyline. "m:h" - Every word of text attached to polyline is placed horizontally in its segment, anchor point is a center of segment. "m:a" - Every word of text attached to polyline is stretched to fit the segment of polyline and placed along that segment. The anchor point is a start of a segment. | ||
p |
|
||
dx, dy | X and Y offset of the label's insertion point.
Applies to text placed on a point, or at each vertex of a polyline. |
||
dp | Perpendicular Offset - For labels placed along a line.
"dp" specifies the perpendicular distance between the label and the line along which it is placed. If the offset is negative then the label will be shifted left of the main segment and right otherwise. |
||
bo | Bold -
If specified, then text will be bold. |
||
it | Italic - | ||
un | Underline - | ||
l | Priority Level - Numeric value defining the order in which style
parts should be drawn. Lower priority style parts are drawn first, and
higher priority ones are drawn on top.
If priority level is unspecified, the default is 1. |
For file formats that do not support tables of styles, then we might want to store them in a text file with a .ofs (OGR Feature Styles) extension and the same basename as the dataset. This would apply to formats like ArcView Shapes.
Here is what one of those .OFS files could look like:
OFS-Version: 1.0 StyleField: "style" DefaultStyle: PEN(C:#000000FF) road: PEN(c:#FF0000,w:5px) lake: BRUSH(fc:#0000FF);LINE(c:#000000) campsite: SYMBOL(c:#00FF00,id:"points.sym-45,ogr-sym-7") label: LABEL(f:"Times New Roman",s:12pt,t:{text_string})
The first line is a signature with a version number. Must be present
The second line (StyleField: "style") is the name of the attribute field in which the Feature Style String is stored for each object in the corresponding layer. This is optional, if not set, then the objects in the layer will all share the same style defined in DefaultStyle.
The third line (DefaultStyle:...) defines the default style that applies by default to all objects that have no explicit style.
Then the list of style definitions follow.
2.8.1 Global list of ids for pen, brush, and symbol ids
There have been discussions about defining a global list of pen, brush, and symbol ids together with a table containing the definition of each code. This would work similarly to the EPSG projection codes, where the table is updated when new codes are added. This would have had some advantages, mainly to provide a common set of codes to replace the vendor-dependent pen, brush and symbol ids. However on the other hand, this mechanism would be redundant with the current approach which is to use a feature style definition language.
2.8.2 Use of custom brushes in pen definitions
In some cases one might want a pen's pattern to be a brush. To achieve this, a PEN() definition would have to contain a BRUSH() definition (e.g. PEN(c:"#FF00FFFF",BRUSH(id:"ogr-brush-4")) or PEN(c:"#FF00FFFF",pen-brush,id:"ogr-brush-4") or ???) but this is currently impossible with the current specs.
Since there is no current need for custom brush patterns in pen (no file formats that we know of support that), we won't include it now but may do it later. In the meantime, one can use the "gp" (geometric pattern) pen parameter to allow specifying one of the OGR brushes as a pen brush pattern.
We can use the OGR_STYLE special field to extract the feature level style, and ogr2ogr can be used to transfer the style string between the data sources according to the following example:
ogr2ogr -f "ESRI Shapefile" -sql "select *, OGR_STYLE from rivers" rivers.shp rivers.tab
Without specifying the length of the style field the output driver may truncate the length to a default value. Therefore it may be necessary to specify the target length manually, like:
ogr2ogr -f "ESRI Shapefile" -sql "select *, CAST(OGR_STYLE AS character(255)) from rivers" rivers.shp rivers.tab
OGR is aware of using the OGR_STYLE field if exists and OGRFeature::GetStyleString will return the value of this field if no style string have been specified programmatically.
Here are some rough ideas:
typedef enum ogr_style_tool_class_id { OGRSTCNone, OGRSTCPen, OGRSTCBrush, OGRSTCSymbol, OGRSTCLabel } OGRSTClassId; typedef enum ogr_style_tool_units_id { OGRSTUGround, OGRSTUPixel, OGRSTUPoints, OGRSTUMM, OGRSTUCM, OGRSTUInches } OGRSTUnitId; typedef enum ogr_style_tool_param_pen_id { OGRSTPenColor = 0, OGRSTPenWidth, OGRSTPenPattern, OGRSTPenId, OGRSTPenPerOffset, OGRSTPenCap, OGRSTPenJoin, OGRSTPenPriority, OGRSTPenLast } OGRSTPenParam; typedef enum ogr_style_tool_param_brush_id { OGRSTBrushFColor = 0, OGRSTBrushBColor, OGRSTBrushId, OGRSTBrushAngle, OGRSTBrushSize, OGRSTBrushDx, OGRSTBrushDy, OGRSTBrushPriority, OGRSTBrushLast } OGRSTBrushParam; typedef enum ogr_style_tool_param_symbol_id { OGRSTSymbolId = 0, OGRSTSymbolAngle, OGRSTSymbolColor, OGRSTSymbolSize, OGRSTSymbolDx, OGRSTSymbolDy, OGRSTSymbolStep, OGRSTSymbolPerp, OGRSTSymbolOffset, OGRSTSymbolPriority, OGRSTSymbolLast } OGRSTSymbolParam; typedef enum ogr_style_tool_param_label_id { OGRSTLabelFontName = 0, OGRSTLabelSize, OGRSTLabelTextString, OGRSTLabelAngle, OGRSTLabelFColor, OGRSTLabelBColor, OGRSTLabelPlacement, OGRSTLabelAnchor, OGRSTLabelDx, OGRSTLabelDy, OGRSTLabelPerp, OGRSTLabelBold, OGRSTLabelItalic, OGRSTLabelUnderline, OGRSTLabelPriority, OGRSTLabelLast } OGRSTLabelParam; //Every time a pszStyleString given in parameter is NULL, the StyleString defined in the Mgr will be use. class OGRStyleMgr { OGRStyleMgr(OGRStyleTable *poDataSetStyleTable =NULL); GBool SetFeatureStyleString(OGRFeature *,const char *pszStyleString=NULL, GBool bNoMatching = FALSE); /*it will set in the given feature the pszStyleString with the style or will set the style name found in dataset StyleTable (if bNoMatching == FALSE)*/ const char *InitFromFeature(OGRFeature *); GBool InitStyleString(const char *pszStyleString = NULL); const char *GetStyleName(const char *pszStyleString= NULL); const char *GetStyleByName(const char *pszStyleName); GBool AddStyle(const char *pszStyleName, const char *pszStyleString=NULL); const char *GetStyleString(OGRFeature * = NULL); GBool AddPart(OGRStyleTool *); GBool AddPart(const char *); int GetPartCount(const char *pszStyleString = NULL); OGRStyleTool *GetPart(int hPartId, const char *pszStyleString = NULL); OGRStyleTable *GetDataSetStyleTable(){return m_poDataSetStyleTable;} OGRStyleTool *CreateStyleToolFromStyleString(const char *pszStyleString); }; class OGRStyleTool { OGRStyleTool(OGRSTClassId eClassId); GBool GetRGBFromString(const char *pszColor, int &nRed, int &nGreen, int &nBlue); int GetSpecificId(const char *pszId, const char *pszWanted); OGRSTClassId GetType(); void SetUnit(OGRSTUnitId,double dfScale = 1.0); //the dfScale will be //used if we are working with Ground Unit ( ground = paper * scale); OGRSTUnitId GetUnit(){return m_eUnit;} void SetStyleString(const char *pszStyleString); }; class OGRStylePen : public OGRStyleTool { /**********************************************************************/ /* Explicit fct for all parameters defined in the Drawing tools Pen */ /**********************************************************************/ const char *Color(GBool &bDefault) void SetColor(const char *pszColor) double Width(GBool &bDefault) void SetWidth(double dfWidth) const char *Pattern(GBool &bDefault) void SetPattern(const char *pszPattern) const char *Id(GBool &bDefault) void SetId(const char *pszId) double PerpendicularOffset(GBool &bDefault) void SetPerpendicularOffset(double dfPerp) const char *Cap(GBool &bDefault) void SetCap(const char *pszCap) const char *Join(GBool &bDefault) void SetJoin(const char *pszJoin) int Priority(GBool &bDefault) void SetPriority(int nPriority) /*****************************************************************/ inline const char *GetParamStr(OGRSTPenParam eParam, GBool &bValueIsNull) inline int GetParamNum(OGRSTPenParam eParam,GBool &bValueIsNull) inline double GetParamDbl(OGRSTPenParam eParam,GBool &bValueIsNull) inline void SetParamStr(OGRSTPenParam eParam, const char *pszParamString) inline void SetParamNum(OGRSTPenParam eParam, int nParam) inline void SetParamDbl(OGRSTPenParam eParam, double dfParam) }; class OGRStyleBrush : public OGRStyleTool { /*a Explicit fct for all parameters defined in the Drawing tools Brush */ const char *ForeColor(GBool &bDefault) void SetForeColor(const char *pszColor) const char *BackColor(GBool &bDefault) void SetBackColor(const char *pszColor) const char *Id(GBool &bDefault) void SetId(const char *pszId) double Angle(GBool &bDefault) void SetAngle(double dfAngle) double Size(GBool &bDefault) void SetSize(double dfSize) double SpacingX(GBool &bDefault) void SetSpacingX(double dfX) double SpacingY(GBool &bDefault) void SetSpacingY(double dfY) int Priority(GBool &bDefault) void SetPriority(int nPriority) /*****************************************************************/ }; class OGRStyleSymbol : public OGRStyleTool { /*****************************************************************/ /* Explicit fct for all parameters defined in the Drawing tools */ /*****************************************************************/ const char *Id(GBool &bDefault) void SetId(const char *pszId) double Angle(GBool &bDefault) void SetAngle(double dfAngle) const char *Color(GBool &bDefault) void SetColor(const char *pszColor) double Size(GBool &bDefault) void SetSize(double dfSize) double SpacingX(GBool &bDefault) void SetSpacingX(double dfX) double SpacingY(GBool &bDefault) void SetSpacingY(double dfY) double Step(GBool &bDefault) void SetStep(double dfStep) double Offset(GBool &bDefault) void SetOffset(double dfOffset) double Perp(GBool &bDefault) void SetPerp(double dfPerp) int Priority(GBool &bDefault) void SetPriority(int nPriority) /*****************************************************************/ }; class OGRStyleLabel : public OGRStyleTool { /*****************************************************************/ /* Explicit fct for all parameters defined in the Drawing tools */ /*****************************************************************/ const char *FontName(GBool &bDefault) void SetFontName(const char *pszFontName) double Size(GBool &bDefault) void SetSize(double dfSize) const char *TextString(GBool &bDefault) void SetTextString(const char *pszTextString) double Angle(GBool &bDefault) void SetAngle(double dfAngle) const char *ForeColor(GBool &bDefault) void SetForColor(const char *pszForColor) const char *BackColor(GBool &bDefault) void SetBackColor(const char *pszBackColor) const char *Placement(GBool &bDefault) void SetPlacement(const char *pszPlacement) int Anchor(GBool &bDefault) void SetAnchor(int nAnchor) double SpacingX(GBool &bDefault) void SetSpacingX(double dfX) double SpacingY(GBool &bDefault) void SetSpacingY(double dfY) double Perp(GBool &bDefault) void SetPerp(double dfPerp) GBool Bold(GBool &bDefault) void SetBold(GBool bBold) GBool Italic(GBool &bDefault) void SetItalic(GBool bItalic) GBool Underline(GBool &bDefault) void SetUnderline(GBool bUnderline) int Priority(GBool &bDefault) void SetPriority(int nPriority) /*****************************************************************/ }; class OGRStyleTable { OGRStyleTable(); GBool AddStyle(const char *pszName,const char *pszStyleString); GBool RemoveStyle(const char *pszName); GBool ModifyStyle(const char *pszName, const char *pszStyleString); GBool SaveStyleTable(const char *pszFilename); GBool LoadStyleTable(const char *pszFilename); const char *Find(const char *pszStyleString); GBool IsExist(const char *pszName); const char *GetStyleName(const char *pszName); void Print(FILE *fpOut); void Clear(); }; Usage examples: OGRStyleTable oStyleTable; OGRStyleMgr *poStyleMgr = new OGRStyleMgr(&oStyleTable); // Create a New style in the style table if (poStyleMgr->AddStyle("@Name","PEN(c:#123456;w:10px);BRUSH(c:345678)")) { poStyleMgr->SetFeatureStyleString(poFeature,"@Name",TRUE) or poStyleMgr->SetFeatureStyleString(poFeature,"PEN(c:#123456,w:10px);BRUSH(c:345678)",FALSE) } oStyleTable->SaveStyleTable("ttt.tbl"); // Create a New style in the style table poStyleMgr->InitStyleString(); poStyleMgr->AddPart("PEN(c:#123456,w:10px)"); poStyleMgr->AddPart("BRUSH(c:345678)"); poStyleMgr->AddStyle("@Name"); poStyleMgr->SetFeatureStyleString(poFeature,"@Name",TRUE); oStyleTable->SaveStyleTable("ttt.tbl"); // Create a New style in the style table OGRStyleTool *poStylePen = new OGRStylePen; poStylePen->SetColor("#123456"); poStylePen->SetUnit(OGRSTUPixel); poStylePen->SetWidth(10.0); poStyleMgr->AddPart(poStylePen); delete poStylePen; // Reading a style; OGRStyleTool *poStyleTool; poStyleMgr->GetStyleString(poFeature); for (i=0;iGetPartCount();i++) { poStyleTool = GetPart(i); switch(poStyleTool->GetType()) { case OGRSTCPen: poStylePen = (OGRStylePen *)poStyleTool; pszColor = poStylePen->Color(bDefault); if (bDefault == FALSE) poStylePen->GetRGBFromString(pszColor, nRed, nGree, nBlue, nTrans); else // Color not defined; dfWidth = poStylePen->Width(bDefault); if (bDefault == FALSE) // Use dfWidth else // dfWidth not defined : : } }