- Thu 12 December 2013
- Simon Dreher
- Linux
- Tags: linux, alacarte, server
About a year ago we were in the third semester and had to attend a lecture called PSE (Practical Software Engineering). There we got the task to write a renderer for OpenStreetMap-Data. Because it has something to do with maps or in german „Karten“, which also stands for menu cards, we gave it the name „alaCarte“. After we finished the lecture we open sourced the project and since then developed it a little bit further. For demonstration purpose we had an instance hosted on a server by a member of the KIT. This one disappeared somewhen in August or September and now I thought to try how big maps I can host on my little home NAS.
Hardware
My Home-NAS contains just a little AMD E350 processor and 4 GiB of RAM. alaCarte uses a lot of RAM, for importing you approximately need the size of the uncompressed OSM-Data as free RAM. For whole Germany this would be around 32GB. For running the server is much less RAM needed. Therefore it is acceptable to use a huge swap partition for importing the data. I didn't want to reformat my disks so I just plugged in an USB-Stick, partitioned it as swap and configured debian to use it. The federal state of Baden-Württemberg worked like a charm, whole Germany was a bit too much: It always stopped at 46% although it had enough free swap space. Probably it just slowed down very much because swap is that much slower than RAM. For Christmas I'm going to make a gift to myself and will upgrade the RAM and try again to import bigger data.
Step-by-step
-
Install dependencies:
sudo apt-get install libboost-all-dev cmake libcairomm-1.0-dev liblog4cpp5-dev
-
Clone the source of alaCarte
git clone https://github.com/alacarte-maps/alacarte.git
-
Build alacarte
cd alacarte mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j <#CPU-Cores>
-
Download and unpack the OSM-XML extract of your choice. A good source for this is the geofabrik-Server
wget -O - http://download.geofabrik.de/europe/germany/baden-wuerttemberg-latest.osm.bz2 | bzcat > bawue.osm
-
Because of the memory consumption I had to mount additional swap space. Using a Flash Drive is not recommended for permanent uses but for importing it does the job. For this you have to first format the USB-Stick to contain a swap partition. Then it has to be added to /etc/fstab according to this instruction and then mount it. You can of course also just create a temporary swap file.
-
Import data (can take some time)
./alacarte-importer bawue.osm bawue.carte
-
Make a user for running the server
sudo adduser alacarte
-
Change ownership of alacarte and data. I would recommend to move the alacarte-server binary, the bawue.carte file, default tile and mapcss directory to a dedicated folder. You can place it anywhere.
mkdir ../server mv alacarte-server ../server mv bawue.carte ../server cp -r ../data/* ../server cd .. sudo chown -R alacarte server cd server
-
Run the server in the background, either use nohup:
sudo su alacarte nohup ./alacarte-server -g bawue.carte -s mapcss -z -1 &
Or use a terminal multiplexer like screen or tmux:
tmux new -s alacarte sudo su alacarte (cd alacarte-dir) ./alacarte-server -g bawue.carte -s mapcss -z -1 <CTRL-B> d
With -z you can set the zoom level until which is prerendered, -1 means, that nothing is prerendered.
-
Configurate your firewall to allow port 8080 or set your webserver to reverse proxy to the alaCarte server.
On my home NAS the server is running using this method, you can try our Demo. Please keep in mind that this is behind a slow DSL connection and the data transmission can be slow. If the rendering process would be slow, you would have to wait for a block of 4x4 tiles (a meta-tile) to render, which then load all at once.
We also of course always welcome new contributors on github.