[gdal-dev] Accessing OGRStyleTable
Geo Aspects Development
dev at geoaspects.com
Sat Sep 13 07:07:39 EDT 2008
FWIW, here are the code fragments I added (to my copy of GDAL 1.4.0),
though I have subsequently changed my strategy and don't use it any
longer. This makes it possible to use the styles in a GUI, where you
can list available styles and have the user select one.
The DataSource/Layer/Feature hierarchy would definitely be useful (to
me!) But, long-term, wouldn't a more standards-based system (including
GDAL and OGR) like SLD be a better idea?
regards
Tim
*******************************************************************************************************
In ogrfeaturestyle.cpp:
/*
=
=
======================================================================
*/
/*
OGRStyleMgr
*/
/*
=
=
======================================================================
*/
...
/
****************************************************************************/
/* const char
**OGRStyleMgr::GetStyleCount() */
/
* */
/
****************************************************************************/
int OGRStyleMgr::GetStyleCount()
{
if (m_poDataSetStyleTable)
{
return m_poDataSetStyleTable->Count();
}
return NULL;
}
/
****************************************************************************/
/* const char
**OGRStyleMgr::GetStyleNames() */
/
* */
/
****************************************************************************/
char **OGRStyleMgr::GetStyleNames()
{
if (m_poDataSetStyleTable)
{
return m_poDataSetStyleTable->GetStyleNames();
}
return NULL;
}
...
/*
=
=
======================================================================
*/
/*
OGRStyleTable */
/* Object Used to manage and store a
styletable */
/*
=
=
======================================================================
*/
...
/
****************************************************************************/
/* int
OGRStyleTable::Count() */
/
* */
/* return the number of styles in the table otherwise return
-1 */
/
****************************************************************************/
int OGRStyleTable::Count()
{
return (m_papszStyleTable == NULL) ? -1 :
CSLCount(m_papszStyleTable);
}
/
****************************************************************************/
/* int
OGRStyleTable::GetStyleNames() */
/
* */
/* return a index of the style in the table otherwise return
-1 */
/
****************************************************************************/
char **OGRStyleTable::GetStyleNames()
{
static char **pszNameList = NULL;
const char *pszName = NULL;
const char *pszStyleStringBegin = NULL;
char *pszTmp;
if (pszNameList)
CSLDestroy(pszNameList);
pszNameList = NULL;
for (int i=0; i<Count(); i++)
{
pszStyleStringBegin = strstr(m_papszStyleTable[i],":");
if (pszStyleStringBegin)
{
pszName = CPLStrdup(m_papszStyleTable[i]);
pszTmp = strstr(pszName,":");
if (pszTmp)
{
pszTmp[0] = '\0';
pszNameList = CSLAddString(pszNameList, pszName);
}
}
}
return pszNameList;
}
...
In ogr_featurestyle.h:
class CPL_DLL OGRStyleMgr
{
...
int GetStyleCount();
char **GetStyleNames();
...
};
class CPL_DLL OGRStyleTable
{
...
int Count();
char **GetStyleNames();
...
};
*******************************************************************************************************
On Sep 13, 2008, at 12:14 AM, Mateusz Łoskot wrote:
> Daniel Morissette pisze:
>> Mateusz Łoskot wrote:
>>>
>>> Now I've got what's the problem.
>>> Yes, looks like this part of API is missing or for some reasons
>>> not planned. Perhaps Daniel or Frank will explain.
>>>
>> Style tables were part of the initial design, but were never
>> implemented for any driver as far as I know. That's why the API may
>> still be incomplete.
>
> Daniel,
>
> Thanks for clarifying it. OGR styling stuff is still a new beast to
> me.
>
>> OTOH, if you have implemented drivers that support style tables
>> then you're invited to contribute tickets, patches, or perhaps a
>> RFC describing what you consider is missing to the API to make it
>> really useful.
>
> Yes, I think it's reasonable approach.
>
> Best regards,
> --
> Mateusz Loskot, http://mateusz.loskot.net
> Charter Member of OSGeo, http://osgeo.org
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list