I'm developing an app that is like a simulation which has to have geoid height for a point(Latitude, Longitude) continuously. Due to the reason that NETGeographicLib demonstrates high performance because of working in GPU and high precision, My prefer is this library instead of PyGeodesy, GeoidHeightDotnet or other between the libraries I know.
1 - However, When I repeatedly force NETGeographicLib's ConvertHeight() method to calculate the geoid height at a point with multithreading as well as six digits precision after the dot in my system, The RAWVAL() method throws an error.
My log says that;
There is an error in Geoid Height Calculation with lat: 41.377132999997144 lon: 28.448859000009104 with the error: GeographicLib.GeographicException: Error reading C:\Users\xxxx\Desktop\xxxx\xxxx\GeoidUndulationCalculatorWPF\bin\Debug\net6.0-windows/geoids\egm96-5.pgm: Index was outside the bounds of the array.
2 - The first opinion that comes to my mind, the digits after the dot may cause the error. If it's how many digits can I use?
3 - Like the error says "egm96-5.pgm: Index was outside the bounds of the array." the searched value in the file is outside of the bounds. So do you know what values are the bounds of "egm96-5.pgm" file?
4 - Or do you know any alternative library that does the same with NETGeographicLib which calculates the geoid height at a point(Lat, Lon) with high performance as well high precision in C#?
Thank you for interesting.
I have found a solution later,
This method below is tested with calculating over 1 million inputs in Multi-Threaded environment. No errors were encountered while the whole process.
1 - Firstly, Take care of that the "EGM96-5.pgm" file has to be read before the multithreading portion.
2 - Though you do it, trying to reach the file concurrently causes that error. So call CacheAll() method via the object created from Geoid Class, after reading the file. Hence, while process is running, any thread is able to easily access to the "EGM96-5.pgm" file without any collision.
Explained in official documentation: CacheAll() Method in Geoid Class
NOTE: Using CacheAll() method just reasons the memory has covers more place which it's only the size of the file(Approximately 18mb for EGM96-5.pgm file).
Hopefully, It is going to help you too.