Code Monkey home page Code Monkey logo

asgard's Introduction

Asgard

Asgard is the interface between Navitia and Valhalla. It can be used to compute street_network direct_paths and matrix.

How to use

To use Asgard with Navitia, you will need to give Jormungandr a configuration file telling Navitia to use Asgard for every street_network_modes you want. This file should be located in the INSTANCE_DIR which is set in the default_settings.py. Here's a (not so) basic one:

{
  "key": "my_instance",
  "zmq_socket": "ipc:///tmp/my_instance_kraken",
  "street_network": [
    {
      "modes": [
        "car",
        "walking",
        "bike"
      ],
      "class": "jormungandr.street_network.asgard.Asgard",
      "args": {
        "service_url": "http://localhost",
        "asgard_socket": "ipc:///tmp/asgard",
        "timeout": 2000
      }
    },
    {
      "args": {
        "street_network": {
          "args": {
            "service_url": "http://localhost",
            "asgard_socket": "ipc:///tmp/asgard",
            "timeout": 2000
          },
          "class": "jormungandr.street_network.asgard.Asgard",
          "modes": []
        }
      },
      "class": "jormungandr.street_network.Taxi",
      "modes": [
        "taxi"
      ]
    }
  ]
}

You can then run Asgard via docker or from the sources.

With docker and navitia-docker-compose

You can clone the repository navitia-docker-compose available here.
Then launch this command at the root directory of the repo 'navitia-docker-compose': docker-compose -f asgard/docker-compose_asgard.yml up

You will have a running Asgard docker with data from France.

To stop the docker, launch this command at the root directory of the repo 'navitia-docker-compose': docker-compose -f asgard/docker-compose_asgard.yml down -v

From the sources

Build from sources

To build Asgard:

git clone https://github.com/CanalTP/asgard.git asgard
cd asgard/scripts
./build_asgard_for_ubuntu.sh -a <path_to_asgard_project>

This will build Valhalla in <path_to_asgard_project>/libvalhalla and install it in <path_to_asgard_project>/valhalla_install.

The executable of Asgard will be located in build/asgard.

Prepare data

To create the data download the pfbs you want here http://download.geofabrik.de/. Then run:

./create_asgard_data.sh -e <path_to_valhalla_executables> -i <path_of_pbf_dir> -o <path_of_output_dir>

By default <path_to_valhalla_executables> will be <path_to_asgard_project>/valhalla_install/bin

Run unit tests

To run the unit tests :

cd build/asgard
ctest

Install linters/formatter

Clang-format-4.0 is used to format our code. A pre-commit hook can be used to format de code before each commit. Before you can run hooks, you need to have the pre-commit package manager installed. Using pip:

pip install pre-commit

To install the pre-commit hooks just do:

pre-commit install

Run linters/formatter

And if you just want to use one pre-commit hook do:

pre-commit run <hook_id>

The CI will fail if the code is not correctly formated so be careful !

More about the dockers

There are 3 differents docker images in the project :

- asgard-build-deps : compiles and installs a specific release of Valhalla and contains all the dependencies to run Asgard.
- asgard-data : creates the configuration file to run asgard and the tiles of a specific pbf. By default it contains the tiles of the whole France.
- asgard-app : compiles and run Asgard with the data of a asgard-data container.

To run Asgard with docker :

# Data of the whole France
docker create --name asgard-data navitia/asgard-data:latest
docker run --volumes-from asgard-data --rm -it -p 6000:6000/tcp navitia/asgard-app:latest

What if I want to use other data ?

It is possible to create an image from the asgard-data dockerfile with any pbf, tag it and create a container from that tagged image. Let's say you want to create an image from the german pbf and tag it "germany" :

cd docker/asgard-data
# Create the image and tag it "germany"
docker build --build-arg pbf_url=http://download.geofabrik.de/europe/germany-latest.osm.pbf -t navitia/asgard-data:germany .
# Create a container from this image
docker create --name asgard-data navitia/asgard-data:germany

asgard's People

Contributors

antoine-de avatar aurelienlp avatar baptisteb-a avatar kinnou02 avatar nonifier avatar texitoi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.