I'm working on a Laravel based application where users can create flights and then view the flight routes on maps. Some of these maps consist of up to 10.000 flights. With these numbers Mapbox would sometimes crash the browser or take a really long time to render, especially since we were using arc.js to calculate the Great Circle routes.
We then switched to creating the flight routes as a single geojson file that was then loaded directly by Mapbox. The maps now load really fast (1-2 seconds instead of up to half a minute), but the routes are straight and do not cross the dateline, which is a real problem as that's not how planes fly.
First I looked for some type of setting within Mapbox that would allow me to render lines as great circles, but I couldn't find anything. Next I looked for PHP libraries similar to arc.js to output the routes to the geojson file, but while there are plenty of libraries that will calculate the distance based on a great circle, I didn't find any that actually produce a route. Currently, I'm looking at the database level. We already use PostGIS, so I thought that there might be a way to use it to calculate the route. So far I have this here, cobbled together from various sources, but it's still throwing errors; ST_MakeLine does not exist...:
SELECT ST_Transform(
ST_Segmentize(
ST_MakeLine(
dep.point,
arr.point
)::geography,
100000
)::geometry,
3857
) as the_geom_webmercator
FROM flights f
LEFT JOIN airports dep ON f.departure_airport_id = dep.id
LEFT JOIN airports arr ON f.arrival_airport_id = arr.id;
I'm kinda hoping that there's a hidden way of displaying curved lines directly in Mapbox, maybe via a source/layer? Failing that, I'd be happy for any pointers for PHP libraries or even PostGIS resources.
Cheers!