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

Create a Wormhole-like Connection in car.lua for Global Routes #7033

Open
maxmaxmaxmaxmaxmaxmax opened this issue Sep 25, 2024 · 3 comments
Open
Labels

Comments

@maxmaxmaxmaxmaxmaxmax
Copy link

Hi,

I’m working on a game and would like to generate something similar to a wormhole.

The basic idea is to modify the car.lua profile so that I can create a connection, for example, from the USA to Asia that goes through the Pacific, making the Earth “round.”

I was thinking that the simplest approach would be to create a connection between two points and set the distance to 0. However, this doesn’t seem to work as expected.

Does anyone have any ideas or could help me with this?

@jcoupey
Copy link

jcoupey commented Sep 26, 2024

You could probably start with a real OSM extract and add "phantom" ways between chosen nodes. I don't think you can really "set the distance to 0", as distances are computed based on coordinates. What you could do instead is making sure the profile sets a weight (internal OSRM cost metric) of 0 to those ways. That would happen by tagging the special ways with a custom "highway"=worm_hole or similar, then adding the matching logic in lua.

@maxmaxmaxmaxmaxmaxmax
Copy link
Author

Thanks so much @jcoupey .
Could you help me find the documentation for the Lua files related to this? I’ve already tried adding them, but I couldn’t find any documentation on the profile Lua scripts.
Which method would I need to adjust?
I tried using process_way but without success. Also, that would change the distance in the calculation, which ultimately affects the fuel consumption. Would you recommend breaking out the “worm_hole” way in a second layer and determining the distance separately?

if data.highway == "worm_hole" then
        result.weight = 0     
  end

also this is not working

if data.highway == "worm_hole" then
        result.weight = 0     
        return 
  end

@jcoupey
Copy link

jcoupey commented Oct 1, 2024

More background info on profiles: https://github.com/Project-OSRM/osrm-backend/blob/master/docs/profiles.md.

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

2 participants