I used a non-macro approach, mainly relying on the geometrical rules. I initially had 544 instead of 516. The difference is due to very thin triangles. So it is an interesting case of which tolerance level to set to test for linearity.
I initially tried to exclude invalid triangles (where the points were all collinear) by using the side lengths, but spatial length/area don't work because these are lat/lons rather than cartesian coordinates!