I have a label layer that I want to filter. Basically, I only want to label features if they appear within a specific polygon on the map. The polygon will be, for example, a county boundary and the labels are the names of towns within that county. I don't want to label the towns that are outside the county.
Is it possible to do this using the LabelLayer.LabelFilter property? If so, how would I go about doing this? I can't find any documentation for this property :(
I'd recomend looking into LabelLayer.Theme property and SharpMap.Rendering.Thematics.CustomTheme namespace. This alows you to setup a delegate (public delegate IStyle CustomTheme.GetStyleMethod(FeatureDataRow dr))); pointing to your filter method. There you can examine your FeatureDataRow and build a Style accordingly.
That's a good idea! I have used themes for other types of layers, such as colouring roads differently depending on their classification, but I didn't think to do it for this - where I would show or hide the label depending on its location.
Ok, I've been looking into this for the past 30 mins and I can't figure out how to check whether a point contained within SharpMap.Data.FeatureDataRow is contained within a polygon! I would have presumed that this would work:
if (poly.Contains(row.Geometry))
{
// Do something
}
where
poly is the polygon, and
row is the row passed to the method. Yet this appears to return
false for all cases including the ones that I
know are definitely within the polygon. Any ideas?
Ah okay. This problem got me thinking, and I realised it was probably a better idea to do the filtering at the data level rather than when it comes to displaying it, so I decided to have a go at doing it using