OpenStreetMap Made Easy
It’s been awhile that I have been trying to understand and setup an Openstreetmap server. It’s easy, one can follow the tutorial at Switch2OSM and do it and I did the same like many others. While I was setting up the Openstreetmap server I was missing a lot of the basic concepts. Although Switch2OSM will get you started I would highly suggest not to follow this tutorial as it is missing a lot of tweaks and details. I found a better tutorial written by our friend Xiao Guoan on his blog post.
I will also suggest, although however lucrative it is, do not attempt to import the whole planet server on the first go, rather stick with a small section and try it first. Whole planet can take a long time to import depending on the hardware used. I tried it on a 24 thread HP DL360 G7 server and it took me over 3 days to find out I will have to start over again.
Most of the time we create our own map server is either for fun (like I did) or we don’t want to pay a service provider like Google Maps or we want to use the map data offline. Let’s look at the different building blocks of a map service so that we can make our own map server with some better understanding.
OpenStreetMap Components
- Map Server: More commonly known as Tile Server, provides the map data to a web client (Eg. Chrome, Firefox or an app on the phone) either in Vector tile format or as a pre-rendered PNG images. Now some tile servers can support both Vector and PNG tile and others are only supporting either vector or per-rendered PNG. Hear is a list of available tile servers.
- Client side library: Client side libraries are used to call the tile server for map data in a more user readable format. Most common format looks like
http://server-domain/zoom/lat/long.ext
Tile Servers don’t use the coordinate system we are familiar with. It uses a system called tile coordinate system. These coordinate system changes as the zoom level changes. Here is a nifty tool if you want to play with tile coordinate system. Client side libraries will also add more common features required for using the map service like for example to put a marker on the map or make a polygon etc. Most common client side libraries are Leaflet and MapBox GL JS Both of these are open source and free to use. Hear is a list of some other client side libraries.
- GeoCoding: In simple word its takes an address as input and spits out the Latitude and Longitude of that particular address. Now why do we need GeoCoding? Most important reason is because our computers don’t understand address but only numbers. It’s the same reason we need a DNS to keep track of a domain to a IP address. There are several open source GeoCoding project but honestly none of them are as good or detailed as Google Maps. The biggest database is available when it comes to open source is with Nominatim. Now as there is GeoCoding we also have Reverse Geocoding and as the name suggests it will give you the address information when a latitude and longitude is supplied.
- Routing: Routing is another important aspect for a mapping service. This service will generate a route between point A to point B. These points can be generated by using Geocoding or by selecting a point on the map. OSRM (Open Source Routing Machine) is my favorite example along with Graphhopper which is also a very popular choice.
That’s it for today hope OpenStreetMap Made Easy was helpful!
References
https://github.com/mapbox/awesome-vector-tiles#servers
https://switch2osm.org/
https://git.siliconbrane.ml/kaushik_ray_1/gps-data-web-server
https://docs.mapbox.com/mapbox-gl-js/api/
https://info.crunchydata.com/blog/dynamic-vector-tiles-from-postgis
https://openlayers.org/
https://leafletjs.com/