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

Are there any examples of applying the diffs to a pbf file? #2

Open
wroolie opened this issue Jul 26, 2023 · 2 comments
Open

Are there any examples of applying the diffs to a pbf file? #2

wroolie opened this issue Jul 26, 2023 · 2 comments

Comments

@wroolie
Copy link

wroolie commented Jul 26, 2023

I've been trying to get this to work for a few days. Using the Nuget package of OSM.Replication seems to always come back with no config (but the actual code and functional tests seem to work great). My big question is how do I apply the diffs? I was using the ApplyChanges function, but can't see the datemodified of the pbf file change-- so no idea if that's actually happening. An example code snippet would be great. Thank you.

@xivk
Copy link
Contributor

xivk commented Aug 1, 2023

I think you are doing it correctly but you also need to save the output stream again to a pbf. If you can share some code perhaps I could comment some more but it's difficult to make out from your explainer.

I myself don't use this code anywhere in a production system at the moment so I can't really claim it's been really field-tested yet so as with any open-source project it's provided as-is, no guarantees.

@wroolie
Copy link
Author

wroolie commented Aug 1, 2023

Thanks so much. And I totally understand there are no guarantees and it is as-is 💯 .

Here's what I'm trying:

var thePast = DateTime.Now.AddHours(-2).AddDays(-5);

            var catchupEnumerator = new CatchupReplicationDiffEnumerator(thePast);
            

            using (var fileStream = new FileInfo(Constants.PbfFile).OpenRead())
            {
                var source = new PBFOsmStreamSource(fileStream);

               

                while (await catchupEnumerator.MoveNext())
                {
                    var current = catchupEnumerator.State;

                    var diff = await catchupEnumerator.Diff();

                    // do something with the diff here!

                    source.ApplyChanges(diff);
                }
            }

I'm opening the filestream, getting the source, downloading the diffs, and trying to applychanges. It's possible I'm being too simple with this and I need to loop through and write all nodes, ways, and relations individually. Would love to help contribute anything I learn. Just not sure if I'm on the right track or not.

Again, really appreciate this code and what you've done.

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