Managed Style

Oct 31, 2006 at 8:04 AM
Hello,

I'm looking for applying a style on a layer but the style is already defined in the shapefile(or the Tab/Map file when i used OGR) but I can't find how to get the style from these files.
The style only contains color or line apparence but if I load a layer all is already in black.

I didn't find any answer searching on the forum or the group so is it possible?

Thanks for your answers.

JB
Nov 2, 2006 at 9:21 AM
HI,

I have exactly the same problem.
Did you find the solution?
Nov 2, 2006 at 11:55 AM
Hi,

I started to modify the gdalwrapper to use the "GetStyleString()" method wich is used in the OGR librayry.

It seems to sends me the style but the creation of the parser of the string is a little bit long.

I had this line in OgrInterop.cs :
DllImport(Gdal.GdalInterOp.GdalDllName)
internal static extern string OGRFGetStyleString(HandleRef hFeat);

and also this function in ogrfeature.cs:
/// <summary>
/// Get the feature style string.
/// </summary>
/// <param name="styleString">The style string applied to this feature.</param>
public string GetStyleString()
{
return OgrInterop.OGRFGetStyleString(this.featureHandle);
}

With this, you can get the style on a feature with the gdalwrapper.
I will put my code if someone are interested on parsing the string when it will be good.

I Hope it could help you.

JB
Nov 2, 2006 at 11:56 AM
I cannot modify my post but "DllImport(Gdal.GdalInterOp.GdalDllName)" is written between"" and ""
Nov 2, 2006 at 2:20 PM
Thanks a lot for the replay,
but i am new in SharpMap,
can you explain in more details about the OGR librayry and gdalwrapper.
And of course i will be grateful if you will post the code.
Thanks a lot.
Nov 2, 2006 at 3:27 PM
http://www.codeplex.com/Wiki/View.aspx?ProjectName=SharpMap&title=OGR%20Provider
The OGR provider is a provider that use fwtools(that you need to download too) and allows you to use TAB or MIF/MID files(and other formats).
I modified the project GdalWrapper(as explained on the top) to get the styles which are inside the files but it will not work for .shp gor the moment(i didn't look at the last version >0.9 of sharpmap so i don't know if themes are managed).

JB
Developer
Nov 3, 2006 at 2:47 AM
Even though you get this to work, there are many of the styles (especially hatches and symbols) that isn't natively supported by SharpMap.
You could probably add the style description as an attribute to the data, and create a CustomTheme to parse these values to the appropriate values.

Anyway, from my point of view MapInfo got it all wrong... Styles doesn't belong in the geometry object. I used to use MapInfo a lot, and the first thing I ALWAYS did was override the default style.
Nov 7, 2006 at 9:12 AM
Thanks for your feed and what about shapefile, is there any way to get the style inside(I only want to get it and store it in a database to apply custom theme later)?
Developer
Nov 7, 2006 at 3:24 PM
Why don't you just create an extra column in your dataset that specifies the style to be used, and use the CustomTheme to create the style based on the data in this column?