Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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

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

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v24.2.dll

NuGet Package: DevExpress.Win.Map

#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