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

ToComplete() overflows stack #122

Open
f2heartz opened this issue Apr 12, 2021 · 1 comment
Open

ToComplete() overflows stack #122

f2heartz opened this issue Apr 12, 2021 · 1 comment
Labels

Comments

@f2heartz
Copy link

f2heartz commented Apr 12, 2021

using OsmSharp.Streams;
using System;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;

namespace Sample.CompleteStream
{
    class Program
    {
        /// <summary>
        /// Downloads a file if it doesn't exist yet.
        /// </summary>
        public static async Task ToFile(string url, string filename)
        {
            if (!File.Exists(filename))
            {
                var client = new HttpClient();
                using (var stream = await client.GetStreamAsync(url))
                using (var outputStream = File.OpenWrite(filename))
                {
                    stream.CopyTo(outputStream);
                }
            }
        }

        static void Main(string[] args)
        {
            ToFile("http://download.openstreetmap.fr/extracts/europe/ukraine//kiev.osm.pbf", "kiev.osm.pbf").Wait();

            using (var fileStream = File.OpenRead("kiev.osm.pbf"))
            {
                // create source stream.
                var source = new PBFOsmStreamSource(fileStream);

                var complete = source.Where(_ => true).ToComplete();

                var counted = complete.GroupBy(osmGeo => osmGeo.Type).Select(group => (group.Key, group.Count()));
                foreach (var (k, v) in counted)
                {
                    Console.WriteLine($"{k}={v}");
                }
            }
        }
    }
}
  1. Run the code above against either current master or with dotnet add package OsmSharp for either netcoreapp2.1 or netcoreapp3.1.
  2. See Stack Overflow printed on the console with no additional info.

P.S. Omitting .Where(_ => true) will fail in the same way.

@xivk xivk added the question label May 10, 2021
@YuriiNskyi
Copy link

Hello, is there any progress on this issue?

I'm currently trying to complete ALL ukraine-latest.osm.pbf using Sample.GeometryStream project. 36.3 GB of RAM was used, with Stack overflow. printed. Seems that situation is quite the same as in the issue.

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

No branches or pull requests

3 participants