Fun with OSM

I have to admit, to me, editing OpenStreetMap is actually a little therapeutic. Sort of like gardening.

My first major contribution was when I brought my little QStarz GPS unit across Indonesia, by train, sitting against the window.

The most recent contribution was our trip to Dubbo, where I helped fill in a few missing roads, and added an initial outlay of Dubbo Zoo.

If you have a GPS or have $60 to spend on one, and like anything CAD-drawing like, give editing OSM a try!

Operation Field

Status: ❌

It is time for a new project. I’ve finally decided I want to do some electronics stuff - at least play around in that realm a little. However, I want to “get out and about” a little as well, so this leads me to my idea: a controllable long-range RC plane.

I’ve been debating whether to go the embedded Linux route, or the more simple microcontroller route. One of the first things I stumbled upon was ArduPilot, a cheap Arduino-based board allowing for a UAV. However, after looking through the requirements I would have needed to purchase an RF transmitter, and they aren’t cheap. This made me rethink the ArduPilot route and to evaluate what I really wanted to do: control the plan. My ultimate goal is to attach a joystick to my computer and be able to control the RC plane. This presents another problem with the ArduPilot, however, as there isn’t an extra Rx pin available on the ArduPilot board (or so the forums say), I wouldn’t be able to transmit coordinates on the fly.

After much research, I think I’ve determined what I’m going to do. I’m ultimately going to adopt the best parts of the ArduPilot, and fill in the gaps with my own board. I’m going to take an EasyStar, combine it with an Arduino Mini, Xbee, XY Sensor, GPS module, servos, H-bridges and a custom PCB, and hope it works.

One thing I’ve learned from YS is to stage our the things I buy. For instance, instead of signing up for a year at a local gym, try a month first. This project won’t be any different, and while most of the equipment is very reasonably priced, I still want to make sure I enjoy this type of thing. The first stage is going to be to buy the Arduino Mini, breadboard, servos and h-bridge (and a cheap DC motor), and see if I can get it all working. If I can, I’ll buy the EasyStar and see if I can control it with a joystick. If still successful, I’ll acquire the Xbees and GPS module - and these represent the majority of the cost.

Another element I’ve considered is how to visualize the RC plane flying around. I had contemplated looking into using Google Earth, but I’d really prefer to use a free variant. I also want to strengthen my Java knowledge, so have opted to use the SDK for WorldWind. I was very excited to see that they also have support for OSM, which is just spectaculous. I plan to have a HUD that on the right displays the plane’s location in WorldWind, and on the left display current altitude, tilt and RF strength. Since I’ve been flying through a book on Processing, this looks like a perfect real-life opportunity to use it.

I’m likely to start putting my money where my mouth is in the next two weeks.

Charting the Hackers

A normal internet connection gets attacked, a lot. The majority of attacks are of the form “hello, anybody there?” – where most people just don’t answer. But sometimes, just sometimes, the question gets an answer. Depending on the answer, the attacker will start to explore.

A few weeks back I was a little bored and started fiddling. I wanted to play with my Cisco, but also wanted to play with OSSEC, but also has a GIS craving. In the end I decided to create a map of the people who ask, “hello”.

Take a look at the map and explanation if that sort of thing is your cup of tea.

Revised mod_tile Install HOWTO

This is the laundry list of things I did while creating a mod_tile VMware appliance based on Ubuntu Server 8.04. I’ve kept descriptions limited but left all the commands in. Let’s start installing things…

Useful goodies for compiling source

sudo apt-get build-essential

More goodies for Mapnik + Friends

sudo apt-get install libboost-dev libboost-filesystem-dev libboost-filesystem1.34.1 libboost-iostreams-dev libboost-iostreams1.34.1 libboost-program-options-dev libboost-program-options1.34.1 libboost-python-dev libboost-python1.34.1 libboost-regex-dev libboost-regex1.34.1 libboost-serialization-dev libboost-serialization1.34.1 libboost-thread-dev libboost-thread1.34.1 libicu-dev libicu38 libstdc++5 libstdc++5-3.3-dev python2.5-dev
sudo aptitude install libfreetype6 libfreetype6-dev libjpeg62 libjpeg62-dev libltdl3 libltdl3-dev libpng12-0 libpng12-dev libtiff4 libtiff4-dev libtiffxx0c2 python-imaging python-imaging-dbg proj
sudo aptitude install libcairo2 libcairo2-dev python-cairo python-cairo-dev libcairomm-1.0-1 libcairomm-1.0-dev libglib2.0-0 libpixman-1-0 libpixman-1-dev libpthread-stubs0 libpthread-stubs0-dev ttf-dejavu ttf-dejavu-core ttf-dejavu-extra
sudo aptitude install libgdal-dev python2.5-gdal postgresql-8.3-postgis postgresql-8.3 postgresql-server-dev-8.3 postgresql-contrib-8.3
sudo aptitude install libxslt1.1 libxslt1-dev libxml2-dev libxml2 gdal-bin libgeos-dev libbz2-dev
sudo aptitude install apache2 apache2-threaded-dev apache2-mpm-prefork apache2-utils
sudo aptitude install subversion

This checks out the mapnik source:

svn co svn://svn.mapnik.org/trunk mapnik-src

Let’s build mapnik with several specific locations included.

cd mapnik-src
python scons/scons.py PYTHON=/usr/bin/python PGSQL_INCLUDES=/usr/include/postgresql PGSQL_LIBS=/usr/lib/postgresql BOOST_INCLUDES=/usr/include/boost BOOST_LIBS=/usr/lib
sudo python scons/scons.py install PYTHON=/usr/bin/python PGSQL_INCLUDES=/usr/include/postgresql PGSQL_LIBS=/usr/lib/postgresql BOOST_INCLUDES=/usr/include/boost BOOST_LIBS=/usr/lib

And prepare a few things for the mapnik rendering…

svn co http://svn.openstreetmap.org/applications/rendering/mapnik/
cd ~/mapnik
wget http://tile.openstreetmap.org/world_boundaries-spherical.tgz
tar -xpjf world_boundaries-spherical.tgz
unzip processed_p.zip
cp coastlines/* world_boundaries/
rmdir coastlines

Time to setup postgres. I have the intentions of running renderd (the mod_tile rendering engine) under whatever user Apache is running as, so I’ll setup postgres to allow the OSM user to authenticate via password. I’m not a postgres expert, so if you see me doing something totally foolish, let me know.

sudo vi /etc/postgresql/8.3/main/pg_hba.conf

And edit the authentication part as so:

# Database administrative login by UNIX sockets
local   all         postgres                          ident sameuser
local   all         osm                               password sameuser

And now to actually configure postgres for the OSM data

sudo su postgres
createuser osm
createdb -E UTF8 -O osm gis
createlang plpgsql gis
psql -d gis -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql
echo "ALTER TABLE geometry_columns OWNER TO osm; ALTER TABLE spatial_ref_sys OWNER TO osm;"  | psql -d gis
echo "alter user osm with password 'columbia';" | psql
sudo /etc/init.d/postgresql-8.3 restart

Now, let’s render a sample image. Edit set-mapnik-env by changing the DB to ‘gis’, the username to ‘osm’, and the password to ‘columbia’

cd mapnik
source ./set-mapnik-env
./customize-mapnik-map >osm.xml
./generate_image.py

If you get an error about it not finding a lib, make sure to do a…

sudo ldconfig

You should have an image called ‘image.png’ in the mapnik directory, and it should look distinctly like the UK.

svn co http://svn.openstreetmap.org/applications/utils/export/osm2pgsql
cd osm2pgsql
make

Ok, that was easy. Let’s load some data. I’ve used a sample snippit from Sydney in /home/osm to illustrate this.

./osm2pgsql -W -d gis ../sydney.osm

Type in the password used for postgres (‘columbia’)

I’ll now check that the data is accessible by editing generate_image.py with the correct coords for Sydney.

ll = (150.29, -34.04, 151.25, -33.36)

Time to get mod_tile up and running.

sudo apt-get install libagg-dev
svn co http://svn.openstreetmap.org/applications/utils/mod_tile
cd mod_tile

Depending on the revision of mod_tile you are using, you are going to have to edit the source before compiling. The two files you need to read through are the Makefile and render_config.h. I change the apxs and apachectl locations to the correct place (lines 2, 13 and 14). Since I did it on a x86 image, I took out any references to lib54 (line 33). In render_config.h, I made the following changes:

Line 8

#define WWW_ROOT "/var/www"

Line 23

#define OSM_XML "/home/osm/mapnik/osm.xml"

Removed references to lib64 on lines 26 and 29.

make && make install

Set it up as a module for apache by creating a file in /etc/apache/conf.d called ‘mod_tile’ and putting in there:

LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so

Created a folder called ‘osm_tiles2’ and ‘direct’ in /var/www, and make sure they are writable by whatever apache runs as (likely www-data). Restart apache.

From here, I created a file that automatically zooms in on the map I just created – you can check it out here. Start the renderd process as www-data, and browse to the sample file.

cd ~/mod_tile
sudo su www-data
./renderd

By now you should have a working mod_tile/OSM setup. After a change and tune a few things on the Ubuntu image I’ll make the VMware image available for download. I can’t wait to do some OSM projects!