Giter Site home page Giter Site logo

etfovac / wmm-c Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 37.15 MB

WMM Point Calculation C++ console (based on C console) uses WMM's C DLL instead of WMM's 'GeomagnetismLibrary.c'

Home Page: https://etfovac.github.io/wmm-c/

License: MIT License

C++ 0.11% C 99.89%
wmm wmm-console cpp c wmm-source dll magneticnorth magnetic-declination compass

wmm-c's Introduction

WMM Point Calculation C++ console uses C DLL

DOI License: MIT

WMM Point Calculation C++ console (based on C console) uses WMM's C DLL instead of WMM's GeomagnetismLibrary.c
(outdated, uses 2014/2015 release from The World Magnetic Model and Associated Software )

Keywords:

WMM, World Magnetic Model
Magnetic Declination Estimation

GeomagnetismHeader.h is header for both DLL and C Library.

extern "C" {
#include "..\code base\GeomagnetismHeader.h"
#include "..\code base\EGM9615.h"
}

Note: WMM.COF file should be in the same folder with DLL C.dll and Console, DLL.exe.

    // DLL is in folder with EXE
    wchar_t Dir[MAX_PATH] = {};
    GetCurrentDirectory(MAX_PATH, Dir);
    string file = "DLL C.dll";
    char path[MAX_PATH];
    sprintf_s(path, "%ls", Dir);
    string FilePath = pathAppend(path, file);
    wstring wsFilePath = wstring(FilePath.begin(), FilePath.end());
    const wchar_t* wcFilePath = wsFilePath.c_str();
    // LoadLibrary
    HMODULE hDLL = LoadLibrary(wcFilePath);
    if (check_ptr(hDLL, path)) { return EXIT_FAILURE; };  

Some of pointers to functions from DLL:

    LPCSTR id = "MAG_Geomag";
    ptr_f_ESGMG MAG_Geomag_ptr = (ptr_f_ESGMG)GetProcAddress(hDLL, id);
    if (check_ptr(MAG_Geomag_ptr, id)) { return EXIT_FAILURE; };
 //...
    id = "MAG_GeomagIntroduction_WMM";
    ptr_f_MV MAG_GeomagIntroduction_WMM_ptr = (ptr_f_MV)GetProcAddress(hDLL, id);
    if (check_ptr(MAG_GeomagIntroduction_WMM_ptr, id)) { return EXIT_FAILURE; };

Some TypeDef allocations:

    typedef int(_cdecl*  ptr_f)();
    typedef int(_cdecl*  ptr_f_MV)(MAGtype_MagneticModel*, char*);
    typedef MAGtype_MagneticModel* (_cdecl*  ptr_f_Mi)(int);
    typedef void(_cdecl*  ptr_f_vi)(int);
    typedef int(_cdecl*  ptr_f_cMi)(char*, MAGtype_MagneticModel* (*)[], int); // problem, use cast
    typedef int(_cdecl*  ptr_f_cii)(char*, uintptr_t, int); //fix
    typedef int(_cdecl*  ptr_f_MGCD)(MAGtype_MagneticModel* , MAGtype_Geoid* , MAGtype_CoordGeodetic* , MAGtype_Date* );

Calling functions:

    b = MAG_GeomagIntroduction_WMM_ptr(MagneticModels[0], VersionDate);
//...
    MAG_FreeMagneticModelMemory_ptr(TimedMagneticModel);
    MAG_FreeMagneticModelMemory_ptr(MagneticModels[0]);

References

Magnetic Field Calculators - Magnetic Declination Estimated Value (NOAA > NESDIS > NCEI (formerly NGDC) > Geomagnetism)
The World Magnetic Model and Associated Software
WMM program ports to other languages

License

This repository includes portions of the WMM source code distributed by NOAA National Centers for Environmental Information (NCEI).

The World Magnetic Model - License and copyright information

The WMM source code is in the public domain and not licensed or under copyright. The information and software may be used freely by the public. As required by 17 U.S.C. 403, third parties producing copyrighted works consisting predominantly of the material produced by U.S. government agencies must provide notice with such work(s) identifying the U.S. Government material incorporated and stating that such material is not subject to copyright protection.

The remaining source code is available under the MIT license

wmm-c's People

Contributors

etfovac avatar

Watchers

 avatar

wmm-c's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.