Styles and themes within same layer

Topics: General Topics
Nov 30, 2006 at 1:56 PM
I have a shapefile which combines several different road types, such as highway, state highways, major roads, substreets.

I dont have the luxury of getting the data broken out. Is it possible to apply different styles to these objects within the same layer? The idea is that highway are a certain color, roads are another, etc, the basics.

I'm thinking this is just not possible. I imagine those road types have some identifying field in the shapefiles / dbf but are just simple multippoint polylines. If anyone can help how to do this, it would be greatly appreciated.
Nov 30, 2006 at 2:50 PM
It should be possible. Have a look at this link: http://www.codeplex.com/Wiki/View.aspx?ProjectName=SharpMap&title=CustomTheme

Add the following code:

//getcountrystyle is the method name that will do the actual styling. See the above URL
SharpMap.Rendering.Thematics.CustomTheme iTheme = new SharpMap.Rendering.Thematics.CustomTheme(GetCountryStyle);
(yourMap.Layers0 as SharpMap.Layers.VectorLayer).Theme = iTheme;

Based on the identifying field in the shapefiles / dbf, you can change the values of the VectorStyle object in the GetCountryStyle method (again, see above URL), to suit how you want that particular data to be drawn.

Hope this helps.
Nov 30, 2006 at 3:46 PM
I had looked at that, but aren't custom themes based upon a geometry object which doesnt really identify the actual underlying object, other than polygon etc?

I believe in the shapefile or dbf it gives some type of a feature class code to indicate this. I think I'm misunderstanding how to make the connection back to the shape file attributes in the example above...

Thank you again.
Nov 30, 2006 at 3:50 PM
Nevermind, I think this example will work great. I missed the style object tree tie in to a feature row. That will resolve the issue. Thank you for your time.