OGRFeature Style C++ API¶
Simple feature style classes.
Typedefs
-
typedef enum ogr_style_type
OGRSType
¶ OGR Style type.
Enums
-
class
OGRStyleTable
¶ - #include <ogr_featurestyle.h>
This class represents a style table.
Public Functions
-
OGRStyleTable
()¶
-
~OGRStyleTable
()¶
-
GBool
AddStyle
(const char *pszName, const char *pszStyleString)¶ Add a new style in the table.
No comparison will be done on the Style string, only on the name.
- Return
TRUE on success, FALSE on error
- Parameters
pszName
: the name the style to add.pszStyleString
: the style string to add.
-
GBool
RemoveStyle
(const char *pszName)¶ Remove a style in the table by its name.
- Return
TRUE on success, FALSE on error
- Parameters
pszName
: the name of the style to remove.
-
GBool
ModifyStyle
(const char *pszName, const char *pszStyleString)¶ Modify a style in the table by its name If the style does not exist, it will be added.
- Return
TRUE on success, FALSE on error
- Parameters
pszName
: the name of the style to modify.pszStyleString
: the style string.
-
GBool
SaveStyleTable
(const char *pszFilename)¶ Save a style table to a file.
- Return
TRUE on success, FALSE on error
- Parameters
pszFilename
: the name of the file to save to.
-
GBool
LoadStyleTable
(const char *pszFilename)¶ Load a style table from a file.
- Return
TRUE on success, FALSE on error
- Parameters
pszFilename
: the name of the file to load from.
-
const char *
Find
(const char *pszStyleString)¶ Get a style string by name.
- Return
the style string matching the name, NULL if not found or error.
- Parameters
pszName
: the name of the style string to find.
-
GBool
IsExist
(const char *pszName)¶ Get the index of a style in the table by its name.
- Return
The index of the style if found, -1 if not found or error.
- Parameters
pszName
: the name to look for.
-
const char *
GetStyleName
(const char *pszName)¶ Get style name by style string.
- Return
the Name of the matching style string or NULL on error.
- Parameters
pszStyleString
: the style string to look up.
-
void
Print
(FILE *fpOut)¶ Print a style table to a FILE pointer.
- Parameters
fpOut
: the FILE pointer to print to.
-
void
Clear
()¶ Clear a style table.
-
OGRStyleTable *
Clone
()¶ Duplicate style table.
The newly created style table is owned by the caller, and will have its own reference to the OGRStyleTable.
- Return
new style table, exactly matching this style table.
-
void
ResetStyleStringReading
()¶ Reset the next style pointer to 0.
-
const char *
GetNextStyle
()¶ Get the next style string from the table.
- Return
the next style string or NULL on error.
-
const char *
GetLastStyleName
()¶ Get the style name of the last style string fetched with OGR_STBL_GetNextStyle.
- Return
the Name of the last style string or NULL on error.
-
-
class
OGRStyleMgr
¶ - #include <ogr_featurestyle.h>
This class represents a style manager.
Public Functions
-
OGRStyleMgr
(OGRStyleTable *poDataSetStyleTable = nullptr)¶ Constructor.
This method is the same as the C function OGR_SM_Create()
- Parameters
poDataSetStyleTable
: (currently unused, reserved for future use), pointer to OGRStyleTable. Pass NULL for now.
-
~OGRStyleMgr
()¶ Destructor.
This method is the same as the C function OGR_SM_Destroy()
-
GBool
SetFeatureStyleString
(OGRFeature*, const char *pszStyleString = nullptr, GBool bNoMatching = FALSE)¶ Set a style in a feature.
- Return
TRUE on success, FALSE on error.
- Parameters
poFeature
: the feature object to store the style inpszStyleString
: the style to storebNoMatching
: TRUE to lookup the style in the style table and add the name to the feature
-
const char *
InitFromFeature
(OGRFeature*)¶ Initialize style manager from the style string of a feature.
This method is the same as the C function OGR_SM_InitFromFeature().
- Return
a reference to the style string read from the feature, or NULL in case of error..
- Parameters
poFeature
: feature object from which to read the style.
-
GBool
InitStyleString
(const char *pszStyleString = nullptr)¶ Initialize style manager from the style string.
This method is the same as the C function OGR_SM_InitStyleString().
- Return
TRUE on success, FALSE on errors.
- Parameters
pszStyleString
: the style string to use (can be NULL).
-
const char *
GetStyleName
(const char *pszStyleString = nullptr)¶ Get the name of a style from the style table.
- Return
The name if found, or NULL on error.
- Parameters
pszStyleString
: the style to search for, or NULL to use the style currently stored in the manager.
-
const char *
GetStyleByName
(const char *pszStyleName)¶ find a style in the current style table.
- Return
the style string matching the name or NULL if not found or error.
- Parameters
pszStyleName
: the name of the style to add.
-
GBool
AddStyle
(const char *pszStyleName, const char *pszStyleString = nullptr)¶ Add a style to the current style table.
This method is the same as the C function OGR_SM_AddStyle().
- Return
TRUE on success, FALSE on errors.
- Parameters
pszStyleName
: the name of the style to add.pszStyleString
: the style string to use, or NULL to use the style stored in the manager.
-
const char *
GetStyleString
(OGRFeature* = nullptr)¶ Get the style string from the style manager.
NOTE: this method will call
OGRStyleMgr::InitFromFeature() if poFeature is not NULL and replace the style string stored in the style manager- Return
the style string stored in the feature or the style string stored in the style manager if poFeature is NULL
- Parameters
poFeature
: feature object from which to read the style or NULL to get the style string stored in the manager.
-
GBool
AddPart
(OGRStyleTool*)¶ Add a part (style tool) to the current style.
This method is the same as the C function OGR_SM_AddPart().
- Return
TRUE on success, FALSE on errors.
- Parameters
poStyleTool
: the style tool defining the part to add.
-
GBool
AddPart
(const char*)¶ Add a part (style string) to the current style.
- Return
TRUE on success, FALSE on errors.
- Parameters
pszPart
: the style string defining the part to add.
-
int
GetPartCount
(const char *pszStyleString = nullptr)¶ Get the number of parts in a style.
This method is the same as the C function OGR_SM_GetPartCount().
- Return
the number of parts (style tools) in the style.
- Parameters
pszStyleString
: (optional) the style string on which to operate. If NULL then the current style string stored in the style manager is used.
-
OGRStyleTool *
GetPart
(int hPartId, const char *pszStyleString = nullptr)¶ Fetch a part (style tool) from the current style.
This method is the same as the C function OGR_SM_GetPart().
This method instantiates a new object that should be freed with OGR_ST_Destroy().
- Return
OGRStyleTool of the requested part (style tools) or NULL on error.
- Parameters
nPartId
: the part number (0-based index).pszStyleString
: (optional) the style string on which to operate. If NULL then the current style string stored in the style manager is used.
-
-
class
OGRStyleTool
¶ - #include <ogr_featurestyle.h>
This class represents a style tool.
Public Functions
-
OGRStyleTool
()¶
-
OGRStyleTool
(OGRSTClassId eClassId)¶ Constructor.
-
~OGRStyleTool
()¶
-
OGRSTClassId
GetType
()¶ Determine type of Style Tool.
- Return
the style tool type, one of OGRSTCPen (1), OGRSTCBrush (2), OGRSTCSymbol (3) or OGRSTCLabel (4). Returns OGRSTCNone (0) if the OGRStyleToolH is invalid.
-
void
SetUnit
(OGRSTUnitId, double dfScale = 1.0)¶ Set Style Tool units.
- Parameters
eUnit
: the new unit.dfGroundPaperScale
: ground to paper scale factor.
-
OGRSTUnitId
GetUnit
()¶ Get Style Tool units.
- Return
the style tool units.
-
const char *
GetStyleString
() = 0¶ Get the style string for this Style Tool.
Maps to the OGRStyleTool subclasses’ GetStyleString() methods.
- Return
the style string for this style tool or “” if the hST is invalid.
-
void
SetStyleString
(const char *pszStyleString)¶ Undocumented.
- Parameters
pszStyleString
: undocumented.
-
const char *
GetStyleString
(const OGRStyleParamId *pasStyleParam, OGRStyleValue *pasStyleValue, int nSize)¶ Undocumented.
- Return
undocumented.
- Parameters
pasStyleParam
: undocumented.pasStyleValue
: undocumented.nSize
: undocumented.
-
const char *
GetParamStr
(const OGRStyleParamId &sStyleParam, OGRStyleValue &sStyleValue, GBool &bValueIsNull)¶ Undocumented.
- Return
Undocumented.
- Parameters
sStyleParam
: undocumented.sStyleValue
: undocumented.bValueIsNull
: undocumented.
-
int
GetParamNum
(const OGRStyleParamId &sStyleParam, OGRStyleValue &sStyleValue, GBool &bValueIsNull)¶ Undocumented.
- Return
Undocumented.
- Parameters
sStyleParam
: undocumented.sStyleValue
: undocumented.bValueIsNull
: undocumented.
-
double
GetParamDbl
(const OGRStyleParamId &sStyleParam, OGRStyleValue &sStyleValue, GBool &bValueIsNull)¶ Undocumented.
- Return
Undocumented.
- Parameters
sStyleParam
: undocumented.sStyleValue
: undocumented.bValueIsNull
: undocumented.
-
void
SetParamStr
(const OGRStyleParamId &sStyleParam, OGRStyleValue &sStyleValue, const char *pszParamString)¶ Undocumented.
- Parameters
sStyleParam
: undocumented.sStyleValue
: undocumented.pszParamString
: undocumented.
-
void
SetParamNum
(const OGRStyleParamId &sStyleParam, OGRStyleValue &sStyleValue, int nParam)¶ Undocumented.
- Parameters
sStyleParam
: undocumented.sStyleValue
: undocumented.nParam
: undocumented.
-
void
SetParamDbl
(const OGRStyleParamId &sStyleParam, OGRStyleValue &sStyleValue, double dfParam)¶ Undocumented.
- Parameters
sStyleParam
: undocumented.sStyleValue
: undocumented.dfParam
: undocumented.
Public Static Functions
-
GBool
GetRGBFromString
(const char *pszColor, int &nRed, int &nGreen, int &nBlue, int &nTransparence)¶ Return the r,g,b,a components of a color encoded in #RRGGBB[AA] format.
Maps to OGRStyleTool::GetRGBFromString().
- Return
TRUE if the color could be successfully parsed, or FALSE in case of errors.
- Parameters
pszColor
: the color to parsenRed
: reference to an int in which the red value will be returned.nGreen
: reference to an int in which the green value will be returned.nBlue
: reference to an int in which the blue value will be returned.nTransparance
: reference to an int in which the (optional) alpha value will be returned.
-
int
GetSpecificId
(const char *pszId, const char *pszWanted)¶ Undocumented.
- Return
Undocumented
- Parameters
pszId
: UndocumentedpszWanted
: Undocumented
Private Members
-
double
m_dfScale
= 1.0¶
-
OGRSTUnitId
m_eUnit
= OGRSTUMM¶
-
OGRSTClassId
m_eClassId
= OGRSTCNone¶
-
char *
m_pszStyleString
= nullptr¶
-