Skip to main content
A newer version of this page is available. .

ShapeSimplifierBase.Simplify(IEnumerable<MapItem>, Double) Method

Reduces the number of vertices that form the vector layer’s items.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v19.2.dll

Declaration

public void Simplify(
    IEnumerable<MapItem> items,
    double tolerance
)

Parameters

Name Type Description
items IEnumerable<MapItem>

The map items to be simplified.

tolerance Double

The percentage of vertices that vector shapes contain after simplification. This value is in the (0;100) range. The passed value is processed as 0 if it is less than 0 or not defined. The passed value is processed as 100 if greater than 100.

Remarks

The example below shows how to simplify items before they are displayed on a vector layer. To do this, call the Simplify method in a data adapter’s ItemsLoaded event handler.

public Form1() {
    InitializeComponent();
    VectorItemsLayer mapLayer = (VectorItemsLayer)mapControl.Layers["MapLayer"];
    ShapefileDataAdapter adapter = new ShapefileDataAdapter() {
        FileUri = new Uri(new Uri(System.Reflection.Assembly.GetEntryAssembly().Location), filename)
    };
    adapter.ItemsLoaded += OnAdapterItemsLoaded;
    mapLayer.Data = adapter;
}
private void OnAdapterItemsLoaded(object sender, ItemsLoadedEventArgs e) {
    VisvalingamShapeSimplifier simplifier = new VisvalingamShapeSimplifier();
    simplifier.Simplify(items: e.Items, tolerance: 50);
}

Alternatively, you can use the DouglasPeuckerShapeSimplifier algorithm instead of the VisvalingamShapeSimplifier.

See Also