| 1 | = RFC 18: OGR Style Support in C API = |
| 2 | |
| 3 | Author: Daniel Morissette[[BR]] |
| 4 | Contact: dmorissette@mapgears.com[[BR]] |
| 5 | Status: Development |
| 6 | |
| 7 | == Summary == |
| 8 | |
| 9 | OGR has a number of C++ classes that deal with the encoding of style information and attaching that to features. More information is available in the http://www.gdal.org/ogr/ogr_feature_style.html document. |
| 10 | |
| 11 | With GDAL/OGR version 1.4.x and older, it was not possible to deal with style information using the C API. This RFC proposes the addition of functions to the C API to manipulate style information in GDAL/OGR 1.5. |
| 12 | |
| 13 | == Implementation Details == |
| 14 | |
| 15 | * The following enums will be moved from ogr_featurestyle.h to ogr_core.h: |
| 16 | |
| 17 | {{{ |
| 18 | OGRSTClassId; |
| 19 | OGRSTUnitId; |
| 20 | OGRSTPenParam; |
| 21 | OGRSTBrushParam; |
| 22 | OGRSTSymbolParam; |
| 23 | OGRSTLabelParam; |
| 24 | OGRSTVectorParam; |
| 25 | OGRSType; |
| 26 | }}} |
| 27 | |
| 28 | * The OGRStyleMgrH (corresponding to the OGRStyleMgr C++ class) will be added to the C API: |
| 29 | |
| 30 | {{{ |
| 31 | OGRStyleMgrH OGR_SM_Create() |
| 32 | void OGR_SM_Destroy(OGRStyleMgrH hSM) |
| 33 | |
| 34 | const char *OGR_SM_InitFromFeature(OGRStyleMgrH hSM) |
| 35 | int OGR_SM_InitFromStyleString(const char *pszStyleString) |
| 36 | int OGR_SM_GetPartCount(OGRStyleMgrH hSM) |
| 37 | OGRStyleToolH OGR_SM_GetPart(OGRStyleMgrH hSM) |
| 38 | int OGR_SM_AddPart(OGRStyleMgrH hSM, OGRStyleTool *sPart) |
| 39 | |
| 40 | OGRStyleToolH OGR_SM_CreateStyleToolFromStyleString(OGRStyleMgrH hSM, const char *pszStyleString) |
| 41 | }}} |
| 42 | |
| 43 | * The OGRStyleToolH (corresponding to the OGRStyleTool C++ class) will be added to the C API: |
| 44 | |
| 45 | {{{ |
| 46 | OGRStyleToolH OGR_ST_Create(OGRSTClassId eClassId) |
| 47 | void OGR_ST_Destroy(OGRStyleToolH hST) |
| 48 | OGRSTClassId OGR_ST_GetType(OGRStyleToolH hST) |
| 49 | |
| 50 | OGRSTUnitId OGR_ST_GetUnit(OGRStyleToolH hST) |
| 51 | void OGR_ST_SetUnit(OGRStyleToolH hST, OGRSTUnitId eUnit, double dfGroundPaperScale) |
| 52 | |
| 53 | int OGR_ST_GetParamIsNull(OGRStyleToolH hST, OGRSTParam eParam) |
| 54 | const char *OGR_ST_GetParamStr(OGRStyleToolH hST, OGRSTParam eParam) |
| 55 | int OGR_ST_GetParamNum(OGRStyleToolH hST, OGRSTParam eParam) |
| 56 | double OGR_ST_GetParamDbl(OGRStyleToolH hST, OGRSTParam eParam) |
| 57 | void OGR_ST_SetParamStr(OGRStyleToolH hST, OGRSTParam eParam, const char *pszParamString) |
| 58 | void OGR_ST_SetParamNum(OGRStyleToolH hST, OGRSTParam eParam, int nParam) |
| 59 | void OGR_ST_SetParamDbl(OGRStyleToolH hST, OGRSTParam eParam, double dfParam) |
| 60 | const char *OGR_ST_GetStyleString(OGRStyleToolH hST) |
| 61 | |
| 62 | int OGR_ST_GetRGBFromString(OGRStyleToolH hST, const char *pszColor, |
| 63 | int *nRed, int *nGreen, int *nBlue, int *nAlpha); |
| 64 | }}} |
| 65 | |
| 66 | * Note that *NO* wrappers will be needed for the following C++ classes which are handled internally by the OGR_ST_* wrappers above: |
| 67 | |
| 68 | {{{ |
| 69 | class OGRStylePen : public OGRStyleTool |
| 70 | class OGRStyleBrush : public OGRStyleTool |
| 71 | class OGRStyleSymbol : public OGRStyleTool |
| 72 | class OGRStyleLabel : public OGRStyleTool |
| 73 | class OGRStyleVector : public OGRStyleTool |
| 74 | }}} |
| 75 | |
| 76 | == Python and other language bindings == |
| 77 | |
| 78 | The initial implementation will be for the C API only and will not be ported/tested with the Python and other scripting language bindings. This will have to wait for a later release. |
| 79 | |
| 80 | == Implementation == |
| 81 | |
| 82 | Daniel Morissette will implement the changes to the C API described in this RFC for the GDAL/OGR 1.5.0 release. |
| 83 | |
| 84 | The first test of the new C API functions will be the conversion of MapServer's mapogr.cpp to use them. |
| 85 | |
| 86 | == Voting History == |
| 87 | |
| 88 | None yet. |