Hey, this is a nice piece of work.
I've been working on a similar project to show 'radar' for our servers.
As part of that, I started out with the idea of putting it on a google map. After a while I gave up on that and used leaflet.js as the map software--it allows you to use any map as your base map, and so we're using an actual IL2 CloD map, which works better in several ways.
However, I messed around with the function to translate CloD coordinates to lat & long, and I thought you might be interested in the results.
Code:
public static Point3d Il2Point3dToLongLat(Point3d pos)
{
//Cubic Regression Curve Fit for four points on various corners of the map done
//via https://www.mycurvefit.com/
//Should is accurate to about the 6th decimal place of the lat/long on those four points, but is
//inaccurate by up to 15km (?) on various points around the map
pos.x = -2.017013 + 0.00001256447 * pos.x + 5.532674e-12 * pos.x * pos.x - 6.478475e-18 * pos.x * pos.x * pos.x;
pos.y = 49.01039 + 0.00000923699 * pos.y - 2.674155e-12 * pos.y * pos.y + 7.598837e-18 * pos.y * pos.y * pos.y;
return pos;
}
Based on my experiments, this is somewhat better than the formula you are using in your package. But it still wasn't really as good as I would have liked. For example, when parked on the runway at Gosport it showed my aircraft somewhere in the middle of the ocean offshore.
This could probably be improved on quite a bit if anyone wants to, by say getting a grid of maybe 16 points around the map, getting their CloD coordinates & real-world lat/lon coordinates very carefully, then putting all that into a curve fitting program like the one at https://www.mycurvefit.com/
I didn't investigate it that thoroughly, but my suspicion is that besides the usual issues of turning a 2-d map & coordinate system in real-world lat/lon, there are also some distortions (perhaps deliberate) in the CloD map so that it really doesn't quite match up with the real map in every detail.
FYI, based on my four selected points--which were near but not quite at the four corners of the CloD map, mycurvefit found these 3 formulas to convert (x,y) coordinates in CloD's system to lat/lon:
Formula #1 (linear):
Code:
lat =0.00000907759*y+49.0913
lon = 0.00001390456*x - 2.097487
Formula #2 (quadratic):
Code:
lat = 49.01703 + 0.000008851254*y+7.476433*10^-13*y^2
lon = -2.041605 + 0.00001312839*x + 1.959212e-12*x^2
Formula #3 (cubic):
Code:
lat = 49.01039 + 0.00000923699*y - 2.674155e-12*y^2 + 7.598837e-18*y^3
lon = -2.017013 + 0.00001256447*x + 5.532674e-12*x^2 - 6.478475e-18*x^3
As you can see, I implemented #3 because it was by far the best fit for my four selected points. But I'm not so sure it really is the best--it might have gotten better accuracy on those four specific points by warping more on what went in between, where I didn't have any points.
Anyway, I'm posting them formulas here just in case anyone wants to fiddle with them.
Bookmarks