Introduction
Navit is an open source navigation software that provides cross-platform navigation capabilities.
Why would your own navigation be a better solution than commonly available navigation on smartphones or tablets? Well, Navit does not collect your data, does not require the Internet connection and contains the latest, up-to-date, detailed maps that can be updated at any time. Moreover, it is free and open source software.
Navit can be run on:
- various operating systems: Linux, Windows, macOS, Android
- mobile devices (smartphones, tablets)
- car navigation systems
This article - as a form of introduction and presentation of possibilities - will present the basic issues of building and configuring Navit on a regular PC with the Debian distribution, but similarly it can be done on any other operating systems, including, of course, Windows or macOS.
With the basic information in hand, in the next article we will build a pocket-sized handheld navigation device for the popular Raspberry Pi device.
How does it work?
The software is available in a ready-to-run (compiled) version here. Preview photos of running naviation are also available.
However, compiling your own software gives you much more opportunities than launching a ready-made application. You can activate functions or disable unnecessary modules, change colors, graphics, set your own maps and much more!
Navit is software that is "powered" by maps downloaded separately. Navit supports several types of maps, but one of the most popular (and current) is OpenStreet Map. This is a powerful database of maps from all over the world, so this article will also describe how to download the area of interest to us.
Software compilation
Repository and libraries
The first step is to download the source code located in the Git repository on GitHub. The latest "trunk" branch contains the current changes, but the latest stable version will be downloaded - v.0.5.6 in this case:
https://github.com/navit-gps/navit
Now just select the button "Code" "Download ZIP".
When viewing or editing code, it is worth having a tool designed for this purpose, e.g. Visual Studio Code, available for download on various platforms here. However, this is not necessary.
To build/compile Navit you will need additional libraries and tools designed for this purpose. To install them on Debian, do the following:
sudo apt update
sudo apt install build-essential cmake libgtk2.0-dev librsvg2-bin libdbus-glib-1-dev libglib2.0-dev libdbus-1-dev libxml2-dev zlib1g-dev libtool librsvg2-bin libsqlite3-dev gpsd gpsd-clients libgps-dev
Compilation and run
In the main directory of the downloaded source code there is a "navit" directory to which you should go:
cd navit
then let's create a build directory and go into it:
mkdir build
cd build
Now we will prepare the project by executing the cmake command, taking into account the project's root directory (../..), and then we will build the whole source code with the make command:
cmake ../..
make
After successful compilation, you can configure Navit to use the appropriate maps and settings. Navit is configured using the navit.xml text file (you can find it in the navit-0.5.6/navit/build/navit output directory). We can run the application itself by issuing the command in the same directory:
./navit
If you encounter an error at some point, it is likely that some libraries/dependencies were not installed correctly or are of the wrong version. In this case, you should examine the build/output messages.
Map configuration
OpenStreet maps can be downloaded in several ways. Due to their large size, it is worth downloading the region we are interested in: https://download.geofabrik.de/
Another way is to select the area of interest using the options "Manually select a different area" and select "Overpass API":
You can save the map under any name, e.g. roma.osm.
The downloaded map must be converted to a format supported by Navit. To do this, install the maptool command and execute:
cat roma.osm | grep "\S" | maptool roma.bin
where roma.osm is the previously downloaded map and roma.bin is the binary output file served by Navit. Additionally, the grep "\S" command is used to remove empty lines, which some versions of maptool do not accept.
The downloaded map should be copied to the directory .../build/navit/maps and the navit.xml file has to be updated to point a new map.
<mapset enabled="yes">
<map type="binfile" data="$NAVIT_SHAREDIR/maps/roma.bin" />
</mapset>
Only one "mapset" entry can be active (enabled="yes"). However, it may contain several maps.
Now, when you start the application, a new map is loaded. If you can't see the new area, it's worth zooming out the map because the starting point may be outside the new map area.
You may encounter other map extensions that need to be converted first. The procedure is analogous for:
PBF:
maptool --protobuf -i my_osm_map.osm.pbf my_navit_map.bin
OSM (sometimes it is required to remove blank lines from OSM
)
maptool -i my_osm_map.osm my_navit_map.bin
BZ2 (compressed)
bzcat my_osm_map.osm.bz2 | maptool my_navit_map.bin
Summary
It is worth noting that this is only the beginning of the possibilities as you have influence on entire source code! When viewing the navit.xml file, you will notice that the user interface is displayed using an HTML structure, which can of course be modified. You can also customize:
- Map display method and colors
- GPS data source (gpsd, static file)
- User elements (zoom in, zoom out, compass, full screen mode)
- Route preferences and much more
Good luck!