CGAL – Computational Geometry Algorithms Library
cgal.org
cgal.org
1. Everything under the sun is implemented!
2. Horrible build system, giant dependency (worse than Boost here)... I wish they had gone header only like Eigen or ViennaCL.
3. Ugly license. Essentially a no-go everywhere I've worked, although still fine for academic projects.
It was tricky to get set up. I was trying to use it as part of a mostly Python utility, and there are SWIG bindings for it that should theoretically have worked, but they were a huge pain and half the core functionality wasn't implemented at all even in the basic 2D kernel. After trying in vain to add the functionality I needed to the SWIG bindings, eventually I just wrote the core algorithm entirely in C++ (despite having no real C++ experience) and called into it from Cython. The API uses enough templated code that it would be hard to get going if you don't have a solid background in C++ or a language with an advanced type system (Haskell in my case).
I didn't find it particularly difficult to get working with Homebrew. Given my scant knowledge of C++ build systems, I would have thought it would be a lot harder. If you are actually a C++ programmer I imagine it would be pretty straightforward.
I agree that the licensing limits its uses quite a bit. The truth is that almost anything you build is probably going to use the GPL'd components. The only things that are LGPL are basic math and the geometry kernels.
http://www.cgal.org/exact.html
I dare to say that 25K is not that much; if you had to do it yourself, it'd be probably very expensive (of course, I don't know how good you are :-) but you see what I mean).
(and yes, I did 2 years of R&D on quad trees with polygon intersections and "exact computation" is super tough to achieve, you need lots of testing)
So it sounds more like you weren't trying to buy the right tool for the job.
To put that in context, 25k is roughly the fully loaded cost of a developer month, if they can do this sort of work properly.
Plenty of specialized libraries out there will cost you twice (or more) as much to acquire and a % on your shipped product.
Thinking of this as expensive is either naive, or just the wrong tool for the job.
I assume that Eigen went header only because that library is mostly template metaprogramming (and a master class at that).
If you need something to just do calculations for display on a Leaflet map, PostGIS/JTS/GEOS/Turf.js will do just fine. If you want to build something that needs to be rock solid, lightning fast, and 100% accurate in all cases, use this library.
Ehhhh depends what bits of CGAL you are using. Their mesh booleans kind of suck.
CGAL's pretty good; they've got an implementation for everything but not all of them are worth using. I just got done reimplementing the RANSAC algorithm in a client's codebase because CGAL's was super slow. But on the whole, it's an amazing feat of open source software.
If you can pony up, though, Parasolid is where it's at. Hands down the most reliable geometry kernel I've ever used, and their support is fantastic.
My use case is mostly for routing and I'm currently using a heavily modified version of OSRM. If there's potential for even more speedup I'd appreciate any resources ou can point me towards.
I'm unaware of CGAL's networking support, our use case depends heavily on the standard DE9-IM relationships. I would look into graph databases like Neo4j for shortest-path and other types of network analysis. They will probably perform better than pgrouting and make it easier for you to conceptualize the problem.
If you need to do huge operations at scale (i.e. things that are just too big to fit in PostGIS and provide reliability/performance) or need 100% accuracy, I would go with straight CGAL. If not, higher level geometric implementations and platforms are probably going to do just fine.
This is like the CAP theorem[1], but for computational geometry libraries. You cannot have all 3 if your truly are aiming for accuracy, speed, or robustness. There is always another edge case (which turns out to be a common case for you), there is always another computational shortcut (cutting out seat belts for cases you know you won't encounter), and there is always a missing function (that you really need). CGAL is a terrific reference implementation for a remarkably diverse set of algorithms, and its commitment to precision in particular is astounding[2].
All that said, never trust the output of a geometry library function that has not been thoroughly fuzz tested. I guarantee that every one of these libraries will fail in surprising ways when subjected to a brutal fuzz tester. I say this as the author of one of the libraries, and as someone who is familiar with the quirks of all of them. In my experience, the best geometry libraries do one tiny task very fast (backed up by benchmarks) and very reliably (verified through unit and fuzz tests).
[1] https://en.wikipedia.org/wiki/CAP_theorem [2] http://www.cgal.org/exact.html
[1] http://angusj.com/delphi/clipper.php [2] https://sourceforge.net/p/jsclipper/wiki/documentation/
I can't comment on the slowness and clunkyness, but in my very limited experience with CGAL I also felt it was needlessly difficult to work with.
Perhaps investing some work in the documentation would help shed this idea.
If anyone ever needs Python bindings for CGAL that make sense, check my little pet project out: https://github.com/wolfv/pygal :)