OGRFeature Style C++ API
Include file
ogr_featurestyle.h
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.
- パラメータ:
pszName -- the name the style to add.
pszStyleString -- the style string to add.
- 戻り値:
TRUE on success, FALSE on error
-
GBool RemoveStyle(const char *pszName)
Remove a style in the table by its name.
- パラメータ:
pszName -- the name of the style to remove.
- 戻り値:
TRUE on success, FALSE on error
-
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.
- パラメータ:
pszName -- the name of the style to modify.
pszStyleString -- the style string.
- 戻り値:
TRUE on success, FALSE on error
-
GBool SaveStyleTable(const char *pszFilename)
Save a style table to a file.
- パラメータ:
pszFilename -- the name of the file to save to.
- 戻り値:
TRUE on success, FALSE on error
-
GBool LoadStyleTable(const char *pszFilename)
Load a style table from a file.
- パラメータ:
pszFilename -- the name of the file to load from.
- 戻り値:
TRUE on success, FALSE on error
-
const char *Find(const char *pszStyleString)
Get a style string by name.
- パラメータ:
pszName -- the name of the style string to find.
- 戻り値:
the style string matching the name, NULL if not found or error.
-
GBool IsExist(const char *pszName)
Get the index of a style in the table by its name.
- パラメータ:
pszName -- the name to look for.
- 戻り値:
The index of the style if found, -1 if not found or error.
-
const char *GetStyleName(const char *pszName)
Get style name by style string.
- パラメータ:
pszStyleString -- the style string to look up.
- 戻り値:
the Name of the matching style string or NULL on error.
-
void Print(FILE *fpOut)
Print a style table to a FILE pointer.
- パラメータ:
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.
- 戻り値:
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.
- 戻り値:
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.
- 戻り値:
the Name of the last style string or NULL on error.
-
OGRStyleTable()
-
class OGRStyleMgr
- #include <ogr_featurestyle.h>
This class represents a style manager.
Public Functions
-
explicit OGRStyleMgr(OGRStyleTable *poDataSetStyleTable = nullptr)
Constructor.
This method is the same as the C function OGR_SM_Create()
- パラメータ:
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.
- パラメータ:
poFeature -- the feature object to store the style in
pszStyleString -- the style to store
bNoMatching -- TRUE to lookup the style in the style table and add the name to the feature
- 戻り値:
TRUE on success, FALSE on error.
-
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().
- パラメータ:
poFeature -- feature object from which to read the style.
- 戻り値:
a reference to the style string read from the feature, or NULL in case of error..
-
GBool InitStyleString(const char *pszStyleString = nullptr)
Initialize style manager from the style string.
Style string can be an expanded style string (e.g. "PEN(c:#FF0000,w:5px)"), or (starting with GDAL 3.5.1), a reference to a style name starting with @ (e.g. "@my_style") registered in the associated style table.
This method is the same as the C function OGR_SM_InitStyleString().
- パラメータ:
pszStyleString -- the style string to use (can be NULL).
- 戻り値:
TRUE on success, FALSE on errors.
-
const char *GetStyleName(const char *pszStyleString = nullptr)
Get the name of a style from the style table.
- パラメータ:
pszStyleString -- the style to search for, or NULL to use the style currently stored in the manager.
- 戻り値:
The name if found, or NULL on error.
-
const char *GetStyleByName(const char *pszStyleName)
find a style in the current style table.
- パラメータ:
pszStyleName -- the name of the style to add.
- 戻り値:
the style string matching the name or NULL if not found or error.
-
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().
- パラメータ:
pszStyleName -- the name of the style to add.
pszStyleString -- the style string to use, or NULL to use the style stored in the manager.
- 戻り値:
TRUE on success, FALSE on errors.
-
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
- パラメータ:
poFeature -- feature object from which to read the style or NULL to get the style string stored in the manager.
- 戻り値:
the style string stored in the feature or the style string stored in the style manager if poFeature is NULL
-
GBool AddPart(OGRStyleTool*)
Add a part (style tool) to the current style.
This method is the same as the C function OGR_SM_AddPart().
- パラメータ:
poStyleTool -- the style tool defining the part to add.
- 戻り値:
TRUE on success, FALSE on errors.
-
GBool AddPart(const char*)
Add a part (style string) to the current style.
- パラメータ:
pszPart -- the style string defining the part to add.
- 戻り値:
TRUE on success, FALSE on errors.
-
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().
- パラメータ:
pszStyleString -- (optional) the style string on which to operate. If NULL then the current style string stored in the style manager is used.
- 戻り値:
the number of parts (style tools) in the style.
-
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().
- パラメータ:
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.
- 戻り値:
OGRStyleTool of the requested part (style tools) or NULL on error.
-
explicit OGRStyleMgr(OGRStyleTable *poDataSetStyleTable = nullptr)
-
class OGRStyleTool
- #include <ogr_featurestyle.h>
This class represents a style tool.
Public Functions
-
inline OGRStyleTool()
-
explicit OGRStyleTool(OGRSTClassId eClassId)
Constructor.
-
virtual ~OGRStyleTool()
-
OGRSTClassId GetType()
Determine type of Style Tool.
- 戻り値:
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.
- パラメータ:
eUnit -- the new unit.
dfGroundPaperScale -- ground to paper scale factor.
-
inline OGRSTUnitId GetUnit()
Get Style Tool units.
- 戻り値:
the style tool units.
-
virtual const char *GetStyleString() = 0
Get the style string for this Style Tool.
Maps to the OGRStyleTool subclasses' GetStyleString() methods.
- 戻り値:
the style string for this style tool or "" if the hST is invalid.
-
void SetStyleString(const char *pszStyleString)
Undocumented.
- パラメータ:
pszStyleString -- undocumented.
-
const char *GetStyleString(const OGRStyleParamId *pasStyleParam, OGRStyleValue *pasStyleValue, int nSize)
Undocumented.
- パラメータ:
pasStyleParam -- undocumented.
pasStyleValue -- undocumented.
nSize -- undocumented.
- 戻り値:
undocumented.
-
const char *GetParamStr(const OGRStyleParamId &sStyleParam, const OGRStyleValue &sStyleValue, GBool &bValueIsNull)
Undocumented.
- パラメータ:
sStyleParam -- undocumented.
sStyleValue -- undocumented.
bValueIsNull -- undocumented.
- 戻り値:
Undocumented.
-
int GetParamNum(const OGRStyleParamId &sStyleParam, const OGRStyleValue &sStyleValue, GBool &bValueIsNull)
Undocumented.
- パラメータ:
sStyleParam -- undocumented.
sStyleValue -- undocumented.
bValueIsNull -- undocumented.
- 戻り値:
Undocumented.
-
double GetParamDbl(const OGRStyleParamId &sStyleParam, const OGRStyleValue &sStyleValue, GBool &bValueIsNull)
Undocumented.
- パラメータ:
sStyleParam -- undocumented.
sStyleValue -- undocumented.
bValueIsNull -- undocumented.
- 戻り値:
Undocumented.
-
void SetParamStr(const OGRStyleParamId &sStyleParam, OGRStyleValue &sStyleValue, const char *pszParamString)
Undocumented.
- パラメータ:
sStyleParam -- undocumented.
sStyleValue -- undocumented.
pszParamString -- undocumented.
-
void SetParamNum(const OGRStyleParamId &sStyleParam, OGRStyleValue &sStyleValue, int nParam)
Undocumented.
- パラメータ:
sStyleParam -- undocumented.
sStyleValue -- undocumented.
nParam -- undocumented.
-
void SetParamDbl(const OGRStyleParamId &sStyleParam, OGRStyleValue &sStyleValue, double dfParam)
Undocumented.
- パラメータ:
sStyleParam -- undocumented.
sStyleValue -- undocumented.
dfParam -- undocumented.
Public Static Functions
-
static 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().
- パラメータ:
pszColor -- the color to parse
nRed -- 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.
- 戻り値:
TRUE if the color could be successfully parsed, or FALSE in case of errors.
-
static int GetSpecificId(const char *pszId, const char *pszWanted)
Undocumented.
- パラメータ:
pszId -- Undocumented
pszWanted -- Undocumented
- 戻り値:
Undocumented
Private Members
-
double m_dfScale = 1.0
-
OGRSTUnitId m_eUnit = OGRSTUMM
-
OGRSTClassId m_eClassId = OGRSTCNone
-
char *m_pszStyleString = nullptr
-
inline OGRStyleTool()