From OpenStreetMap Wiki
(Redirected from Cgimap)
Jump to navigation Jump to search

CGImap screenshot.png
Author: See list of contributors
License: GPL-2.0 (free of charge)
Platform: Linux/Ubuntu 22.04
Version: 0.8.8 (2022-07-27)
Language: English
Source code:
Programming language: C++17

CGImap is a re-implementation of selected performance critical parts of the OSM API 0.6 in C++ (in productive use)


CGImap is a C++ implementation of selected performance critical parts of the OSM API 0.6 using the FastCGI interface. It was originally developed to overcome performance limitations present in the openstreetmap-website Rails application, including but not limited to large memory consumption, slow XML parsing, overall slow execution.

As CGImap doesn't manage any database schemas and tables on its own, it can only be deployed alongside the openstreetmap-website application to replace selected API endpoints by their performance optimized counterparts, see Section Production Deployment. CGImap directly interacts with the API DB, and completely bypasses the openstreetmap-website Rails application.

An important design principle is that for every feature, a Rails port counterpart needs to be implemented first, which doubles as a reference implementation.


Currently, CGImap implements:

  • the "map" API call
  • single node, way and relation fetches
  • multiple node, way and relation fetches
  • the "full" way and relation calls
  • changset metadata downloads, including discussions
  • single node, way and relation history calls
  • single node, way and relation specific version fetches
  • multiple node, way and relation specific version fetches
  • changeset downloads
  • changeset uploads

(Always check the project GitHub repo for an up-to-date list.)

Supported output formats include OSM XML and OSM JSON. For user authentication Basic Auth, OAuth1.0a or OAuth 2.0 can be used.

Deviations from Rails port

  • Diff upload rejects empty keys.
  • Diff upload relies on SQL to create new object version and changeset timestamps, thereby ignores the time reported by the frontend server.


Installation instructions are available on the project's GitHub repo.


Customer quotes

  • We have some hidden magic that makes the website faster for editing. [...] A few years ago we implemented that and you could notice how much quicker the API was.[1]
  • I got it to run as an editable map yesterday but immediately discovered I need cgimap to make it anywhere close to usable.[2]
  • The cgi-map implementation of the diff upload endpoint is blazingly fast[3]

Faster implementation → less hardware needed:

  • From today the mapping API is now >30% more energy efficient with no reduction in performance. We have removed the need for separate backend API servers.[4]