Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All

I have a problem where I have to figure out the Magnetic Variation of a point.

Here's the background. I want to use the industry standard for figuring out Magnetic Variation. It's located at here. I've downloaded the file WMM2010GUI.zip and within it has a program called WMM.exe. This program does exactly what I want. You put a Lat, Long and height and then you push calculate and then it figures out the declination.

So, within the zip file is also what I believe is the code to this exe but the problem is that it's in C++. Is there a way to use the code in a C# project? I want to pass at least 4 variables to it, Lat, Long, Height and Date. How do I do this?

There's two parts to this. The first is getting the declination and then the next is that I have a whole list of points within an Access table that looks like this - Lat, Lon, Height, Date, MagVar
45.11,-34.11,100,2013-Jan-1,
65.11,89.11,100,2013-Jan-1,

Has anyone ever done something like this? Also, how do I add a C++ project with my C# project?

Thanks

Mike
Posted

1 solution

Depends on what type of C++ it is: if it is CLR code, then you can just add it as a reference and call it's methods as if they were C# - the framework will sort it all out for you.

If it is native C++ code, then you may be able to use it, but you will have to read up on P/INVOKE and will have to find out what functions the C++ code exposes.

You can add a C++ CLR project to your solution very easily: Right click the solution and select "Add...Existing Project..." then follow the dialogs from there.

The other alternative is to use it as is: you can execute it as a process and it may be possible to provide it with command line arguments to make it work without it's GUI (which I assume it has from your "push calculate" comment.

There is another option: rewrite the C++ code which does the work in C# (and ignore the GUI if you don't need it).

Sorry, but we can't give a definitive answer based on that little info! :laugh:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900