This project has moved. For the latest updates, please go here.


Topics: SharpMap v0.9 / v1.x
May 30, 2008 at 4:40 PM
Edited May 30, 2008 at 4:43 PM

is it possible in SharpMaxExtension project, OgrProvider.cs file to modify the ExecuteQuery function to manage the style of the feature.
You can see my modifications in bold .
This code could allow us to read the Style which is include in the ogr files(like MapInfo files). After that we can parse the string to get the color, symbol, ... directly from the file.

public FeatureDataSet ExecuteQuery(string query, Geometry filter)
FeatureDataSet ds = new FeatureDataSet();
FeatureDataTable myDt = new FeatureDataTable();

Layer results = _OgrDataSource.ExecuteSQL(query, filter, "");

//reads the column definition of the layer/feature
ReadColumnDefinition(myDt, results);
OSGeo.OGR.Feature _OgrFeature;
while ((_OgrFeature = results.GetNextFeature()) != null)
FeatureDataRow _dr = myDt.NewRow();
for (int iField = 0; iField < _OgrFeature.GetFieldCount(); iField++)
if (myDt.Columns[iField].DataType == System.Type.GetType("System.String"))
_dr[iField] = _OgrFeature.GetFieldAsString(iField);
else if (myDt.Columns[iField].GetType() == System.Type.GetType("System.Int32"))
_dr[iField] = _OgrFeature.GetFieldAsInteger(iField);
else if (myDt.Columns[iField].GetType() == System.Type.GetType("System.Double"))
_dr[iField] = _OgrFeature.GetFieldAsDouble(iField);
_dr[iField] = _OgrFeature.GetFieldAsString(iField);

_dr.Geometry = this.ParseOgrGeometry(_OgrFeature.GetGeometryRef());
_dr["Style"] = _OgrFeature.GetStyleString();

return ds;
catch (Exception exc)
return new FeatureDataSet();

May 30, 2008 at 10:58 PM
Hi Jean-Baptiste,

There is actually an entire OGC spec on handling style data that we are looking at implementing. A "style provider" would be a candidate to implement this spec, and return style data from any given source. The OGR provider could then implement it. This would allow us to be more flexible and not build too many concerns into the data provider architecture. If you need something soon, then you can feel free to do this yourself, since the source is available. If you would submit a patch, then people could use it as they need to. Thanks for the input!