Snapping to Taxiways
How does snapping to taxiways work?
Aircraft on the ground shall follow the taxiway layout of the airport:
KATL: Lineup at 26L along taxiway centerlines
A couple of things need to work together to make that happen:
  1. 1.
    The taxiway layout needs to be known. It is read from the scenery files. Scenery does matter now!
  2. 2.
    The aircraft tracking positions need to be close enough to a taxiway (distance configurable in Advanced Settings).
  3. 3.
    For rolling on taxiways even between any two reported tracking positions, a shortest path must be determinable, which allows the aircraft to go from one known tracking position to the next without becoming too fast (path must not be too long) and by avoiding sharp turns.

Reading the Taxiway Layout

LiveTraffic reads through the installed scenery as X-Plane itself does: as per your Custom Scenera/scenery_packs.ini file, and then as a final step also reads the default scenery. LiveTraffic is only interested in the Earth nav data/apt.dat files of sceneries as it contains the airport layout. Its format is documented (though the documentation wasn't up to date at the time of coding ;-))
For each airport in the vincinity of the current camera position, LiveTraffic reads all taxiway centerlines. So it actually bases on the visual feature of lines, and not on the so-called "taxiroute network", which is used by X-Plane's AI planes on the ground: The taxiroute network does by far not cover all real taxiways, but real aircraft do use real taxiways. Moreover, LiveTraffic also reads runway and gate/ramp location.
LiveTraffic needs to perform numerous optimization on the taxiway centerlines. For example, it needs to identify where taxiways cross/join, it needs to reduce the number of nodes for efficiency, and it needs to apply Bezier curves when curves have been modeled this way.
The following 2 screenshots, one from the modelling tool WorldEditor, one from a data dump out of LiveTraffic, show what LiveTraffic makes out of the data:
KATL as represented by LiveTraffic (click for larger view)
This graphic is drawn by GPS Visualizer, based on a data of the taxiway network dumped by debugging versions of LiveTraffic. GPS Visualizer is a great tool for showing geo locations on maps and helped me tremendously during development and bug fixing!
KATL, about the same area, as modelled in the WorldEditor
WED is where scenery is modeled. It essentially is the basis for the scenery data that lands in apt.dat. Data above is the Scenery Gateway version of KATL as included in X-Plane by default.
The screenshot also shows that things aren't perfect...reality never is. For example some roads are marked with taxiway centerlines, too (far left of the screenshot). Not a big problem as long as aircraft don't actually go there... If you look closely you may find, e.g., that lines aren't always connected although they should: Look at the beginning of the runway: the taxiway onto the runway (blue) is not actually connected with the actual runway (red). Such gaps are a problem during shortest-path finding, see below.

Snapping a Position

LiveTraffics prime principle is that a plane has to be at the position as reported from tracking data by the time the tracking data includes. Inbetween any two reported tracking positions, LiveTraffic has some freedom to model the plane's path.
Any tracking position on the ground will be snapped to the nearest edge in the taxiway layout. That sounds simple, and in fact the code is short. But it has its own problems when the taxiway network is modeled as detailed as LiveTraffic does: Have a look at the following situation:
Detail of medium-complex joining taxiways
This is a detail out of the above network for KATL. It is not even the most complex intersection of taxiways found... But let's assume that the tracking data for a plane reports the position as indicated by the red star: On which edge, on which taxiway is that plane currently? Even if you consider its current heading (and LiveTraffic does) it is not fully clear: If the plane is roughly heading north in that location, then it could still go the left way directly north or make the right turn just a little late and continue west.
So snapping to taxiways can be off, too, especially at intersections, even simple ones. And then we might be on the wrong path, and that again is bad for finding shortest paths. If we assumed the plane goes straight north, but the next data point we receive some time later is actually in the far west, then there is no valid taxiway path any longer.

Finding a Shortest Path

...between any two given nodes isn't a big deal, just apply Dijkstra. And that's what LiveTraffic does to keep a plane on the taxiway, even if available tracking positions are a bit away of each other. It is certainly optimized for plane usage: The path must not become too long (otherwise the plane would need to run too fast...remember: we have a date with the next position!), and we must not turn too sharp, so in the above picture of joining taxiways we would avoid turning nearly 180° around at the joint marked by the light blue triangle in the top left corner.
That works all great as long as none of the above mentioned problems is in the way:
  • Gaps in the taxiway network, especially missing joints between runways and taxiways
  • Guessed the "wrong" edge when snapping a position
So we don't always find shortest valid paths. And then the plane will just go direct between any two positions, ignoring the taxiways.

You found something where it's always wrong?

I'm interested! Given the sharp decline in airtraffic due to Corona, I could test all this complex logic only in a few US airports (unbelievable, how much air traffic there still was!). So there are hundreds of big airports out there with their all very unique layout. I am absolutely sure that there are still avoidable bugs in all these algorithms.
What I need from you:
  • Where are you? Which airport, which particular place on this airport? (Screenshot out of X-Plane, but better even a screenshot from Openstreet Map or Google Maps)
  • Planes going wrong when they move in which direction? When they do which kind of turns?
  • What is a good time to observe this behaviour? Planes usually follow schedules. So if there are many at some time of the day then chances are they will be there again next least next week same day.
  • Ideally a video out of X-Plane. Remember that I can and will only follow up on reoccuring if it is reoccurring, then you actually can do a video.
Put all that in a post in the support forum and I have a chance to follow up. Thank you!