Is there a way to generate an OSRM file using geojson information?

I am in possession of a geojson datafile that contains paths labeled as highway=footway, and I am interested in utilizing OSRM for finding routes between multiple points (similar to the travelling salesman problem rather than just the most direct route from A to B).

After examining the OSRM documentation, I discovered that in order to use customized data instead of OpenStreetMap data, I would require an OSRM file. This can allegedly be created by executing the OSRM binaries located in node_modules/osrm/lib/binding/ along with default profiles.

I find this process to be quite ambiguous and I am unsure how to proceed. Although the aforementioned documentation references the OSRM-backend documentation, I could not locate any information regarding the creation of OSRM files there. Even after obtaining the node_modules/osrm directory via npm, the osrm/lib/binding directory is empty...

What steps should I take to incorporate my data into OSRM routing? Alternatively, if there exists a simpler solution to my goal, what approach would you recommend?

Answer №1

Through a specific process, I managed to generate an osrm file:

  1. To start, either convert the geojson file to osm using JOSM, or work directly with an osm file. In JOSM, you can open the geojson file and go to File > Save As... to save it in OSM file format.
  2. Add version, timestamp, and changeset tags using osmconvert:
$ osmconvert64 intput_file.osm --fake-author -o=output_file.osm
  1. Convert the osm file into a binary file with osmosis:
$ osmosis --rx input_file.osm --wb output_file.osm.pbf omitmetadata=true
  1. Utilize the OSRM Docker container to create the osrm file. First, ensure Docker desktop is installed:
$ docker run -t -v "absolute/path/to/data":/data osrm/osrm-backend osrm-extract -p /opt/profile.lua /data/file_name.osm.pbf
$ docker run -t -v "absolute/path/to/data":/data osrm/osrm-backend osrm-contract /data/file_name.osrm

Important Notes:

  • When executing the docker step, establish a data directory and ensure the absolute path to data points to that directory.
  • Ensure that the file_name used remains consistent between the osrm-extract input and the osrm-contract output, as OSRM creates additional files with that name which are required for the contract step.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to utilize a Git token for accessing private repositories when integrating with Travis CI and Cloudfoundry?

Setup CF CLI version cf version cf version 6.37.0+a40009753.2018-05-25 Buildpack version https://github.com/cloudfoundry/nodejs-buildpack Configuration File applications: - path: . memory: 2048M instances: 1 buildpack: nodejs_buildpack nam ...

Angular: Delaying the return until the $http request has successfully completed

I am facing a challenge in my main module where I need to create a service that can parse a json file and store its contents in an array. The intention is to make this array easily accessible by all controllers. However, the issue arises because the func ...

Guide to showcasing a component in reactjs based on a conditional statement?

Here is an example of code snippet. import React, { Component } from "react"; import Navpills from "./Navpills"; import Home from "./pages/Home"; import About from "./pages/About"; import Blog from "./pages/Blog"; import Contact from ". /pages/Contact"; ...

Convert time display to a 24-hour format using JavaScript

I managed to convert the time format from GMT to my browser's local time using the following JavaScript code: var newDate = new Date(timeFromat); timeFormat = newDate.toLocaleString(); Now, I want to change the time format to a 24-hour clock format ...

Obtaining localStream for muting microphone during SIP.js call reception

My approach to muting the microphone involves using a mediastream obtained through the sessionDescriptionHandler's userMedia event. session.sessionDescriptionHandler.on('userMedia', onUserMediaObtained.bind(this)) function onUserMediaObta ...

Challenges arise when dealing with the dimensions of a webpage while loading it with Jquery

Having an interesting problem here - I'm utilizing Jquery to load an HTML content into a Div element, however, strangely enough, the width and height are not adjusting as expected. Here's the snippet causing the trouble: $("#middlebox").html(&ap ...

Update View Not Reflecting React State Increment

Here is the code snippet I am currently working with: class PickColor extends React.Component { constructor(props) { super(props); this.state = { active: 0 } this.setState = this.setState.bind(this); } ...

Stop contenteditable from inserting a div element when the Enter key is pressed using only JavaScript, and

Is there a way to prevent the contenteditable feature from adding a div when Enter key is pressed, using pure JavaScript instead of jQuery? I found an example that uses jQuery here: http://jsfiddle.net/uff3M/, but I specifically need a solution in plain J ...

Having trouble getting mongoose's updateOne with upsert feature to function properly

let basket = req.body.params.cart // array of objects that require updating if found in the database, or inserting if not present. let userID = req.body.params.uid for (let i = 0; i < basket.length; i++) { Cart.updateOne({ user: userID, 'cart ...

Top-tier Reactjs Infinite Scroll library that prioritizes optimal performance

I'm creating a calendar with numerous days that requires scrolling to view the content, causing performance issues in the application. Are there any specific techniques or libraries available in reactjs to enable smooth scrolling functionality like t ...

Saving JSON values in Angular session storage

I am working with a php file that sends back JSON data after using a $http post method. You can see the json result here. Now, in my controller below, I want to save either `03-1314-00916` or `data[0]['student_number']` as a session in Angular s ...

Effortless pagination across various pages, utilizing diverse CSS selectors

I've integrated simple pagination into my website, but I've encountered a issue. My navigation consists of CSS tabs, each holding a unique pagination component. Here is the jQuery pagination code snippet: $(function(){ var perPage = 8; var open ...

Is it possible to generate a "pop-up" window upon clicking on the register button?

As a backend programmer, I'm looking to create a popup window that appears in front of the current window when users click "register", eliminating the need for redirection to another page. I believe you understand the concept. How can I achieve this? ...

Tips for harnessing the power of a massive TypeScript library without cluttering up your html code

This answer suggests adding references to .js files generated by all the used .ts files manually. I am planning to utilize a library with a intricate structure. I have already included the main files in my html, but they include sub-references that in tur ...

Alter data in MongoDB based on specific circumstances

Currently, I am utilizing node.js and mongoose for a project. The task at hand involves updating database information only if the required field either does not exist in the database or its value is less than 'x'. Specifically, this pertains to ...

Getting precise coordinates on a transparent PNG file using JavaScript Canvas

https://i.sstatic.net/Zw8is.png Hey there, I'm a bit puzzled about the getImageData function mentioned on this page. I have an image in png format with a transparent background. My goal is to retrieve the x and y coordinates for both left and right ...

The sendgrid mail import feature is currently experiencing technical difficulties and is not functioning as

I encountered an issue while attempting to send email using the @sendgrid/mail module. The code snippet I used is shown below: import * as sgMail from '@sendgrid/mail'; function sendMail(msg) { sgMail.setApiKey("API-KEY"); sgMail.send(msg, ...

A more effective approach than relying on an abundance of else if statements

I need to improve my Javascript code that handles different text options: var personUrls = { 'amy': 'http://www.mydomain.com/amylikescats.html', 'dave': 'http://www.mydomain.com/daveshome.html', 'steve': & ...

Mapping an array using getServerSideProps in NextJS - the ultimate guide!

I'm facing an issue while trying to utilize data fetched from the Twitch API in order to generate a list of streamers. However, when attempting to map the props obtained from getServerSideProps, I end up with a blank page. Interestingly, upon using co ...

Issues with JavaScript functionality arise when a modal is loaded using AJAX and TWIG

I'm experiencing an issue with my Javascript. I've created a Javascript modal function that uses AJAX to retrieve content, and then the innerHTML function places that content into the modal. While the modal displays the content correctly, the Jav ...