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

Problems with calculating route from contracted graph #375

Open
MrDeXik opened this issue May 30, 2024 · 0 comments
Open

Problems with calculating route from contracted graph #375

MrDeXik opened this issue May 30, 2024 · 0 comments

Comments

@MrDeXik
Copy link

MrDeXik commented May 30, 2024

Hello, I want to calculate route and show the result on map in MAUI App. So I need to calculate the route fast even on mobile phone. To achieve this, firstly I run my app on PC, which:

  • loads data from osm.pbf file
  • adds contracted graph for profile Vehicle.Car.Fastest()
  • serialize the routerdb to file on PC
    This is the code:
var routerDb = new RouterDb();
var input = new FileInfo(@"C:\Users\zdene\Downloads\czech-republic-latest.osm.pbf").OpenRead();
routerDb.LoadOsmData(input, Vehicle.Car);
routerDb.AddContracted(Vehicle.Car.Fastest());
using (var output = new FileInfo(@"C:\Users\zdene\Downloads\czech-republic-cartest.routerdb").Open(FileMode.Create))
{
        routerDb.Serialize(output);
}

Then I take the generated file, transfer it to my mobile phone's documents and serialize it to AppDataDirectory of MAUI App
This is the code:

var routerDb = new RouterDb();
var result = await FilePicker.Default.PickAsync();
using var stream = await result.OpenReadAsync();
routerDb = RouterDb.Deserialize(stream);
string localGdbFilePath = Path.Combine(FileSystem.Current.AppDataDirectory, "czech-republic.routerdb");
routerDb.Serialize(File.Create(localGdbFilePath));
router = new Router(routerDb);

Then when running app, I use this code to load routerdb from AppDataDirectory:
router = new Router(RouterDb.Deserialize(File.OpenRead(localGdbFilePath), RouterDbProfile.NoCache));
When I try to calculate route from the same file on PC, it works perfectly and fast, but when I try the same task for the same coordinates from the same file on mobile, it fails with error:

No edge found from 576420 to 0.

I tried a lot of variants to solve this, but nothing works. Also, calculating the route on mobile without previously adding contracted graph to the file works correctly, but takes too long when calculating slightly longer distances. So I need to make it faster.
I don't know where is the problem or what I am doing wrong.
I would appreciate any advice. I hope someone could help me.

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

1 participant