OGRADIONSE风格C++ API

Simple feature style classes.

类型定义

typedef enum ogr_style_type OGRSType

OGR Style type.

枚举类型

enum ogr_style_type

OGR Style type.

Values:

enumerator OGRSTypeUnused
enumerator OGRSTypeString
enumerator OGRSTypeDouble
enumerator OGRSTypeInteger
enumerator OGRSTypeBoolean
class OGRStyleTable
#include <ogr_featurestyle.h>

This class represents a style table.

公共职能

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.

私人成员

char **m_papszStyleTable = nullptr
CPLString osLastRequestedStyleName = {}
int iNextStyle = 0
class OGRStyleMgr
#include <ogr_featurestyle.h>

This class represents a style manager.

公共职能

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.

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.

私人成员

OGRStyleTable *m_poDataSetStyleTable = nullptr
char *m_pszStyleString = nullptr
class OGRStyleTool
#include <ogr_featurestyle.h>

This class represents a style tool.

公共职能

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, OGRStyleValue &sStyleValue, GBool &bValueIsNull)

Undocumented.

参数
  • sStyleParam -- undocumented.

  • sStyleValue -- undocumented.

  • bValueIsNull -- undocumented.

返回

Undocumented.

int GetParamNum(const OGRStyleParamId &sStyleParam, OGRStyleValue &sStyleValue, GBool &bValueIsNull)

Undocumented.

参数
  • sStyleParam -- undocumented.

  • sStyleValue -- undocumented.

  • bValueIsNull -- undocumented.

返回

Undocumented.

double GetParamDbl(const OGRStyleParamId &sStyleParam, 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.

公共静态函数

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

私人职能

virtual GBool Parse() = 0

私人成员

GBool m_bModified = false
GBool m_bParsed = false
double m_dfScale = 1.0
OGRSTUnitId m_eUnit = OGRSTUMM
OGRSTClassId m_eClassId = OGRSTCNone
char *m_pszStyleString = nullptr