Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can use RasterizingLayer and open IsMapInfoLayer=true,performance degradation #2595

Open
Misacky opened this issue Apr 16, 2024 · 1 comment

Comments

@Misacky
Copy link

Misacky commented Apr 16, 2024

Mapsui Version
5.0.

Mapsui Platform
Avalonia.

Device
Windows.

@pauldendulk
Copy link
Member

You have to give me a bit more information. When I turn MapInfo in the 'RasterizingTileLayer with Points' I don't see anything special.

using Mapsui.Extensions;
using Mapsui.Layers;
using Mapsui.Styles;
using Mapsui.Tiling;
using Mapsui.Tiling.Layers;
using Mapsui.Widgets;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

#pragma warning disable IDISP004 // Don't ignore created IDisposable

namespace Mapsui.Samples.Common.Maps.Performance;

public class RasterizingTileLayerWithPointsSample : ISample
{
    public string Name => "RasterizingTileLayer with Points";
    public string Category => "Performance";

    public Task<Map> CreateMapAsync()
    {
        var map = new Map();
        map.Layers.Add(OpenStreetMap.CreateTileLayer());
        map.Layers.Add(new RasterizingTileLayer(CreateRandomPointLayer()) {  IsMapInfoLayer = true});
        var extent = map.Layers[1].Extent!.Grow(map.Layers[1].Extent!.Width * 0.1);
        map.Home = n => n.ZoomToBox(extent);
        map.Widgets.Add(new MapInfoWidget(map));
        return Task.FromResult(map);
    }

    private static MemoryLayer CreateRandomPointLayer()
    {
        var rnd = new Random(3462); // Fix the random seed so the features don't move after a refresh
        var features = new List<IFeature>();
        for (var i = 0; i < 100; i++)
        {
            features.Add(new PointFeature(new MPoint(rnd.Next(0, 5000000), rnd.Next(0, 5000000))));
        }

        return new MemoryLayer
        {
            Name = "Points",
            Features = features,
            IsMapInfoLayer = true,
            Style = new SymbolStyle
            {
                SymbolType = SymbolType.Triangle,
                Fill = new Brush(Color.Red)
            }
        };
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants