[gdal-dev] OGR style fields

Tamas Szekeres szekerest at gmail.com
Fri Jan 18 15:42:18 EST 2008


Folks,

Currently only a few of the OGR data sources have built in style
support, however we might want to preserve the style information when
copying the data from one data source to another.
As of the implementation of GDAL RFC 6 we could do such things easily
regardless of the target data source type, like for example:

ogr2ogr -overwrite -f "ESRI Shapefile" -sql "select *,OGR_STYLE from
rivers where OGR_GEOMETRY='POLYGON'" rivers.shp rivers.tab

would copy all of the polygons from a mapinfo layer and add a new
field containing the style string for each of the features.

It would be quite trivial to prepare a data source independent support
to consume this information and return meaningful value when
OGRFeature::GetStyleString is called.

As the benefit of this change we could consider each of these layer as
having internal style information. For example we could use the
mapserver STYLEITEM "AUTO" functionality with these layers.

The most trivial implementation to achieve this would changing
OGRFeature::GetStyleString as follows:

const char *OGRFeature::GetStyleString()
{
    int  iStyleField;

    if (m_pszStyleString)
        return m_pszStyleString;

    iStyleField = GetFieldIndex("OGR_STYLE");
    if (iStyleField >= 0)
        return GetFieldAsString(iStyleField);

    return NULL;
}

What do you think about this kind of addition?

Best regards,

Tamas


More information about the gdal-dev mailing list