The GIS++ tutorial aims to give an introduction into C++ for those who already know another imperative programming language like Java, JavaScript, or Python. In order to follow this tutorial, you should prepare your computer to get a simple development system.

Prepare your system

TL;DR

Ideally, your system needs to have

  • a C++11/C++14 compliant compiler (can you run g++ and make in a terminal?),
  • a modern boost library unpackaged to a reasonable location (we don’t need compiled sub-libraries, so you don’t need to build boost or rely on the packages from your distribution, which might be outdated)
  • A git client
  • [Optional] A GIS software

Install a compiler

Windows

Here are some steps to download and install a sensible G++ compiler on Windows:

  • Download cygwin installer (setup-x86-64.exe) from https://cygwin.com/install.html. Cygwin provides a GNU / POSIX environment on top of the Windows operating system.
  • Install whatever package you like (I used mingw64-x64-w64-gccg++) just in order to get a cygwin installation directory
  • Copy the just downloaded setup-x86_64.exe to your newly created directory (c:\cygwin64 in my case). This program can be used as a package manager as well.
  • Start the Cygwin64 Terminal (has been installed while setting up cygwin)
  • cd / => now you are in the location where we put setup-x86_64.exe, you can check with ls
  • Run ./setup-x86_64.exe -q -P wget -P gcc-g++ -P make -P diffutils -P libmpfr-devel -P libgmp-devel -P libmpc-devel. This step downloads some packages needed to compile programs
  • Optionally: Install git (if you don’t have a Git for Windows installation yet) ./setup-x86_64.exe -q -P git
  • Enter cd<Enter> bringing you into your home (~)
  • Clone: git clone https://www.github.com/mwernerds/spatial-cpp
  • Download Boost from https://www.boost.org/users/download/ (ZIP version)
  • Extract it and copy the boost subfolder cygwin area to /usr/include in your cygwin folder, like C:\cygwin64\usr\include. In theore, you can put it anywhere, but then you need to update the Makefiles to know the location.

Note: You could install boost from cygwin package manager, but then you might end up with a slightly different version, hence, we prefer the given way.

Mac Users:

  • Make sure that some compiler is installed (g++ in terminal should be working, clang is just fine)
  • Download and unpack boost from https://www.boost.org/users/download/ to some convenient location (remember this location to update / influence the Makefiles)
  • Clone: git clone https://www.github.com/mwernerds/spatial-cpp and update makefiles or set environment variable BOOST_HOME Linux Users: Install g++ (GNU C++ compiler, any current version is fine) Download and unpack boost from https://www.boost.org/users/download/ to some convenient location (remember this location to update / influence the Makefiles)

Linux Users

  • Depending on your distribution, just install a compiler, download boost (see Mac) and copy the boost folder to /usr/local/include.

Instructions and software are available from https://www.qgis.org/. QGIS is not essential to the tutorial, but it can visualize the input and output of our nearest neighbor and range query example.

Download the source code

Use your favourite git to clone:

git clone https://github.com/mwernerds/spatial-cpp

Some Additional Material

The git you just cloned contains most of the material we will be discussing in some detail. If you want to look at the road ahead, you can

  • study my (winning!) GISCUP 2015 submission https://github.com/mwernerds/giscup2015. It combines the Boost Graph Library, Boost Geometry, Shapelib, and DSLAB to implement a fast and flexible shortest path engine on top of OSM.
  • study DSLAB https://github.com/mwernerds/dslab, which provides a pretty minimal wxWidgets-based portable GUI with OpenGL support (used in GISCUP 2015).
  • study libtrajcomp https://github.com/mwernerds/trajcomp in which TRACLUS algorithm and some trajectory distances are implemented in portable C++ and made available as an R package for the data science language R.
  • study frechet https://github.com/mwernerds/frechetrange how existing source-code can be shielded (this is the top 3 submissions to the GISCUP 2017 on Fréchet range queries) into a header-only library and how this can be bound to Python and R at the same time.
  • search the Internet for amazing examples of modern C++ and don’t forget that WebAssembly allows you to run compiled C++ code in all major browsers (with some limitations on the amount of memory) including OpenGL ES support.

The original proposal for the tutorial is available as well (Werner, 2019)

For discussions, additions, and your amazing insights from this tutorial, use the github interaction features (issues for problems, questions, and requests, pull requests for adding your own illustrative code).

Bibliography

  1. Werner, M. (2019). GIS++: Modern C++ for Efficient and Parallel In-Memory Spatial Computing. In 1st ACM SIGSPATIAL International Workshop on Geospatial Data Access and Processing APIs (SpatialAPI’19). [PDF] [BibTeX]