Faster than earcut: triangulating 3.7M map polygons in 489 ms

A developer has released 'earstrip,' a new C++ library for polygon triangulation that significantly outperforms the industry-standard 'earcut' library. The post details the technical optimizations and geometric principles used to achieve faster rendering speeds for map data.
Why it matters
Efficient geometric processing is critical for high-performance mapping software and real-time rendering in modern web and desktop applications.
We have published the polygon triangulator of our map engine as a small library, earstrip , under the ISC license, the same one earcut uses. It is one C++ header, and a WebAssembly build on npm that takes the same arguments as earcut. In C++ it is 14% faster than earcut.hpp, in the browser 1.4 to 2.1 times as fast as earcut.js, and the comparison is near the end. This post is about how we got there.
A GPU fills triangles and nothing else. A map, on the other hand, is mostly polygons: buildings, parks, parking lots, the strip of grass between two tram tracks. Here are a few blocks of Śródmieście in Warsaw the way our renderer reads them from a map file, as outlines :
Get smarter about the news
Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.
Create free accountAlready have an account? Sign in