Tangram: an open source map rendering library

I have a Raspberry Pi project that I’d love to use street maps for, but it would be a daunting challenge for me to figure out how to read map data and write the code to draw the maps on screen. It’s why I was delighted to discover Tangram ES, which is a library for rendering 2D and 3D maps using OpenGL ES 2 with data from OpenStreetMap. The library works on a number of devices, including of course Raspberry Pi.

Patricio Gonzalez Vivo (from the video above) and the team at Mapzen are responsible for the open source project, which is an offshoot of their WebGL map rendering library, Tangram. While Tangram ES is still a work-in-progress, they’ve been using Raspberry Pi 2 to speed up their development of the library and they’re ready for more people to take it for a spin.

Structured a lot like a research and development lab, Mapzen is a startup founded with the idea that mapping done collaboratively, transparently, and in the open can produce more resilient software, and ultimately, better maps. Their focus is on open source tools and using open data to create the building blocks for future mapping applications, including search & geocoding, routing, and transit, in addition to the rendering work they’re doing with Tangram.

Patricio is a graphics engineer on Tangram, responsible for implementing different graphical features such as tessellation, lights, materials, environmental maps, and other CG effects. The team also includes Brett Camper, who is Mapzen’s co-founder, as well as Peter Richardson, Ivan Willing, and Karim Naaji. The ES version of Tangram was started by Matt Blair and Varun Talwar.

“Last December Karim and I thought it could be interesting to get Tangram ES running on a Raspberry Pi,” said Patricio. “At the beginning we thought it would be difficult and probably slow, but at the end we were surprised by the speed of the app and how easy the implementation was. Cross-platform C++ development is possible!”

“In a way, the Pi is an ideal test platform for developing graphics software that targets low-power systems,” said Matt. “The OpenGL ES 2 implementation on the Pi is the strictest that we’ve encountered, so it has become our gold standard for ensuring correct usage of OpenGL. The only major missing piece on the Pi was a compiler that supports C++11, which Tangram uses extensively. However since the Pi is a complete Linux distribution, installing the packages we needed with apt was a breeze.”

Don’t have to take Matt’s word for it; you can install and test drive Tangram ES on the Raspberry Pi right now:

Installing Tangram ES

Using Raspbian, here’s how to install the Tangram ES library from the command line and execute the included sample code:

sudo apt-get update
sudo apt-get install cmake g++-4.7 libcurl4-openssl-dev
cd ~
git clone https://github.com/tangrams/tangram-es.git
cd tangram-es
git submodule init && git submodule update
make rpi
cd build/rpi/bin


AndrewS avatar

Nice! Much prettier than the 2D DXF map renderer I once wrote for the PocketPC platform ;-) (which relied on bigger-than-the-screen buffers and background rendering to achieve smooth scrolling)

Does OpenGL ES allow bigger-than-the-screen buffers to allow a similar approach to be used here?

Pete avatar

wow .. super nice guy .. super smart project!

Bantammenace avatar

Aren’t maps brilliant ?
Here’s the thing: The Ordnance Survey in the UK have made their mapping available as OS OpenData for Minecraft. One example they show is “A ramble through Snowdonia in GB Minecraft 2”. Is it possible to use that data with Tangram on an RPi2 combined with a GPS to be used whilst out and about?.
That would be a fine example of Art mimicking real life.

Martin O'Hanlon avatar

I love a map.

I especially love an electronic map.

Federico avatar

Excellent project, a wonderful idea and a magnificent execution.

AndrewS avatar

The location of the Big Birthday Bash this weekend:

MalMan35 avatar

Any news about the Christmas Competition 2014?

roger smith avatar

On a B2, builds quick and easy with make -j6.
Minor documentation –
q quit
w a s z up, left, right, down
– zoom out
= zoom in
Doesn’t need X-windows, runs straight from command line.
add -m to command line to use mouse.

Convinced me the GLES has a future.
Now to add Lat. and Long. to command line to start somewhere more meaningful to me than Manhattan.

roger smith avatar

And now the bad news — left alone for about 10 mins gives error
“*** longjump causes uninitialised stack frame ***: ./tangram terminated”

Patricio Gonzalez Vivo avatar

Hi Roger, can you post an issue on the github repo of tangram-es?

I will personally work on the lat lon args + GPS hat integration soon.


Aaron avatar

How do you get out the software

Patricio Gonzalez Vivo avatar

Press q to quit

Glenn avatar

That, I a noob to raspberry and linux was able to get it to work at all without bricking my sd card (again) is wonderous.

I would love to be able to figure out how to implement Tangram with my honda odyssey touring’s internal GPS. Or perhaps replace it with a pi! The computer (WinCE) unfortunately also seems to interface to the Backing Camera (Very Important to me!!!) & radio and perhaps other systems. (YES, I believe that there is a market for replacing the poor software in people’s cars as even if I pay honda $200.00 for new maps they seem not to upgrade the software which often picks things over 1500 miles as the closest McDonnalds OR Walmart or whatever.)

The mouse drag works well but the roller wheel does not zoom.

I was caught unawares that there were no menus visible. This might have been an overscan issue with my 42″ panasonic plasma tv (BSD OS! could this be rooted and fixed?) of 50 PX Left&Right and 35 px up and down, (in the best case after adjusting the tv ‘format’ to ‘full’) but given the comments I thought I’d give it a mention.

So just to prevent folk from shock or having to turn off the PI I suggest:
1:Let folk know that the ALT TAB will not work to exit to something else.
2:Give the commant set prior to instructions to do the build and start Tangram.
3: change the above behaviours and make sure that the program has some easy way to limit the screen usage to the non overscanned portion.

Matt Richardson avatar

Keep in mind that Tangram is a library for developers to use in their projects. The program that you launched is just the compiled sample code which demonstrates the library’s basic features. I wouldn’t expect advanced functionality out of it.

Markus avatar

Very nice!
Any nauticians there?
It would be great to see OpenSeaMap in this way!

Aaron Pearson avatar

i can`t install it (have done one and it worked but having to do it again because my old SD card broke and setting up my new one)

Aaron Pearson avatar

this is what happens to it if it helps seeing how to fix this.

pi@raspberrypiA ~/tangram-es $ make rpi
— The C compiler identification is GNU 4.6.3
— The CXX compiler identification is GNU 4.6.3
— Check for working C compiler: /usr/bin/gcc
— Check for working C compiler: /usr/bin/gcc — works
— Detecting C compiler ABI info
— Detecting C compiler ABI info – done
— Check for working CXX compiler: /usr/bin/c++
— Check for working CXX compiler: /usr/bin/c++ — works
— Detecting CXX compiler ABI info
— Detecting CXX compiler ABI info – done
— Platform chosen : RASPBERRYPI
— Including raspberrypi dependent cmake file : /home/pi/tangram-es/toolchains/raspberrypi.cmake
CMake Error at toolchains/raspberrypi.cmake:14 (message):
Please install g++ version 4.7 or greater
Call Stack (most recent call first):
CMakeLists.txt:50 (include)

— Configuring incomplete, errors occurred!
Makefile:164: recipe for target ‘cmake-rpi’ failed
make: *** [cmake-rpi] Error 1

P.S it says to install g++ 4.7 but I do have this

threedogs avatar

Succesfully installed gcc 4.8 and set to standard
1%] Building CXX object core/CMakeFiles/core.dir/src/style/polygonStyle.cpp.o
[ 93%] Building CXX object core/CMakeFiles/core.dir/src/style/style.cpp.o
/root/tangram-es/core/src/style/style.cpp: In member function âvoid Style::apply LayerFiltering(const Feature&, const Context&, std::bitset&, StyleParamMap &, std::shared_ptr) constâ:
/root/tangram-es/core/src/style/style.cpp:123:23: error: no match for âoperator= â (operand types are â__gnu_cxx::__normal_iterator<std::shared_ptr*, std::vector<std::shared_ptr > >â and âvoidâ)
sLayerItr = sLayers.insert(sLayers.end(), ssLayers.begin(), ssLayer s.end());
/root/tangram-es/core/src/style/style.cpp:123:23: note: candidates are:
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/vector:60,
from /root/tangram-es/core/src/data/tileData.h:3,
from /root/tangram-es/core/src/style/style.h:3,
from /root/tangram-es/core/src/style/style.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:708:11: note: __gnu_cxx::__normal_itera tor<std::shared_ptr*, std::vector<std::shared_ptr > >& __gnu_cxx::__normal_iterator<std::shared_ptr*, std::vector<std::shared_ptr > >::operator=(const __gnu _cxx::__normal_iterator<std::shared_ptr*, std::vector<std:: shared_ptr > >&)
class __normal_iterator
/usr/include/c++/4.8/bits/stl_iterator.h:708:11: note: no known conversion for argument 1 from âvoidâ to âconst __gnu_cxx::__normal_iterator<std::shared_ptr*, std::vector<std::shared_ptr > >&â
/usr/include/c++/4.8/bits/stl_iterator.h:708:11: note: __gnu_cxx::__normal_itera tor<std::shared_ptr*, std::vector<std::shared_ptr > >& __gnu_cxx::__normal_iterator<std::shared_ptr*, std::vector<std::shared_ptr > >::operator=(__gnu_cxx:: __normal_iterator<std::shared_ptr*, std::vector<std::shared _ptr > >&&)
/usr/include/c++/4.8/bits/stl_iterator.h:708:11: note: no known conversion for argument 1 from âvoidâ to â__gnu_cxx::__normal_iterator<std::shared_ptr*, std::vector<std::shared_ptr > >&&â
core/CMakeFiles/core.dir/build.make:1020: recipe for target ‘core/CMakeFiles/cor e.dir/src/style/style.cpp.o’ failed
make[3]: *** [core/CMakeFiles/core.dir/src/style/style.cpp.o] Error 1
make[3]: Leaving directory ‘/root/tangram-es/build/rpi’
CMakeFiles/Makefile2:120: recipe for target ‘core/CMakeFiles/core.dir/all’ faile d
make[2]: *** [core/CMakeFiles/core.dir/all] Error 2
make[2]: Leaving directory ‘/root/tangram-es/build/rpi’
Makefile:113: recipe for target ‘all’ failed
make[1]: *** [all] Error 2
make[1]: Leaving directory ‘/root/tangram-es/build/rpi’
Makefile:168: recipe for target ‘rpi’ failed
make: *** [rpi] Error 2

Please assist!!

Comments are closed