-
Notifications
You must be signed in to change notification settings - Fork 305
Expand file tree
/
Copy pathFilterProvider.cs
More file actions
55 lines (51 loc) · 2.35 KB
/
FilterProvider.cs
File metadata and controls
55 lines (51 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
namespace SharpMap.Data.Providers
{
/// <summary>
/// Abstract class for providers which support the FilterMethod Delegate
/// </summary>
public abstract class FilterProvider
{
#region Delegates
/// <summary>
/// Filter Delegate Method
/// </summary>
/// <remarks>
/// The FilterMethod delegate is used for applying a method that filters data from the dataset.
/// The method should return 'true' if the feature should be included and false if not.
/// <para>See the <see cref="FilterDelegate"/> property for more info</para>
/// </remarks>
/// <seealso cref="FilterDelegate"/>
/// <param name="dr"><see cref="SharpMap.Data.FeatureDataRow"/> to test on</param>
/// <returns>true if this feature should be included, false if it should be filtered</returns>
public delegate bool FilterMethod(FeatureDataRow dr);
#endregion
/// <summary>
/// Filter Delegate Method for limiting the datasource
/// </summary>
/// <remarks>
/// <example>
/// Using an anonymous method for filtering all features where the NAME column starts with S:
/// <code lang="C#">
/// myShapeDataSource.FilterDelegate = new SharpMap.Data.Providers.ShapeFile.FilterMethod(delegate(SharpMap.Data.FeatureDataRow row) { return (!row["NAME"].ToString().StartsWith("S")); });
/// </code>
/// </example>
/// <example>
/// Declaring a delegate method for filtering (multi)polygon-features whose area is larger than 5.
/// <code>
/// myShapeDataSource.FilterDelegate = CountryFilter;
/// [...]
/// public static bool CountryFilter(SharpMap.Data.FeatureDataRow row)
/// {
/// if(row.Geometry.GetType()==typeof(GeoAPI.Geometries.IPolygon))
/// return ((row.Geometry as GeoAPI.Geometries.IPolygon).Area>5);
/// if (row.Geometry.GetType() == typeof(GeoAPI.Geometries.IMultiPolygon))
/// return ((row.Geometry as GeoAPI.Geometries.IMultiPolygon).Area > 5);
/// else return true;
/// }
/// </code>
/// </example>
/// </remarks>
/// <seealso cref="FilterMethod"/>
public FilterMethod FilterDelegate {get;set;}
}
}