Get Plane Coordinates of P3D

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
Locked
hkhoanguyen
Posts: 46
Joined: Sat Feb 21, 2015 8:45 am

Get Plane Coordinates of P3D

Post by hkhoanguyen »

Hi,

I would like to know how to get plane coordinates broadcasting by P3D ? I want to develop a moving map actually,

Thanks in advanced.
nealmac
Posts: 178
Joined: Mon Jul 18, 2016 11:11 pm
Location: Ireland (Ardee hey)

Re: Get Plane Coordinates of P3D

Post by nealmac »

If you hit Shift+Z it will display your coordinates at the top left of the screen.
Best Regards,

Neal McCullough.
hkhoanguyen
Posts: 46
Joined: Sat Feb 21, 2015 8:45 am

Re: Get Plane Coordinates of P3D

Post by hkhoanguyen »

nealmac wrote: Tue Oct 17, 2017 10:10 am If you hit Shift+Z it will display your coordinates at the top left of the screen.
Sorry if there is anything not clear in my question.

I wanted to get the GPS Coordinates of the plane in real time in order to develop a moving map that shows the plane actual position on the map.
User avatar
WarpD
Posts: 1469
Joined: Mon Feb 14, 2011 5:29 am

Re: Get Plane Coordinates of P3D

Post by WarpD »

Have you read the SDK?
Ed Wilson
Senior Developer
Mindstar Aviation
hkhoanguyen
Posts: 46
Joined: Sat Feb 21, 2015 8:45 am

Re: Get Plane Coordinates of P3D

Post by hkhoanguyen »

WarpD wrote: Tue Oct 17, 2017 3:59 pm Have you read the SDK?
Hi, Thanks for your reply,

I read the SDK and following to the example of getting the Data from Data Request Class.

However, I had this error while running my visual studio solution :
System.BadImageFormatException occurred
HResult=0x8007000B
Message=Could not load file or assembly 'LockheedMartin.Prepar3D.SimConnect, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source=WindowsFormsApp1
StackTrace:
at WindowsFormsApp1.Form1..ctor() in C:\Users\P3D-PC\source\repos\ConsoleApp1\WindowsFormsApp1\Form1.cs:line 53
at WindowsFormsApp1.Program.Main() in C:\Users\P3D-PC\source\repos\ConsoleApp1\WindowsFormsApp1\Program.cs:line 19
LockheedMartin.Prepar3D.SimConnect.dll is added into my References.

I also tried to target to both x86 and x64 and Any CPU

Do you have any idea of how to solve this? Thanks
User avatar
WarpD
Posts: 1469
Joined: Mon Feb 14, 2011 5:29 am

Re: Get Plane Coordinates of P3D

Post by WarpD »

Why would you directly reference the DLL? I am not familiar with C# but shouldn't you be referencing SimConnect with it's header and library and not the DLL? Also, ensure you're using the correct version of Visual Studio.
Ed Wilson
Senior Developer
Mindstar Aviation
JB3DG
Posts: 609
Joined: Mon Jan 09, 2012 6:44 pm

Re: Get Plane Coordinates of P3D

Post by JB3DG »

@Ed There are a number of ways to link dlls in C#. Here is a snippet from one of my config manager projects that is in C#. The dlls (Xceed.Wpf.Toolkit.dll and SharpDX.DirectSound.dll) are then to be included in the installer, preferably in the same location as the exe.


using Xceed.Wpf.Toolkit;
using Xceed.Wpf.Toolkit.Themes;
using SharpDX.DirectSound;



There is another way I link to certain core system dlls. For example GetPrivateProfileString and WritePrivateProfileString. I simply place the following members in my C# base class.


[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section,
string key, string def, StringBuilder retVal,
int size, string filePath);
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,
string key, string val, string filePath);


@hkhoanguyen if you go to your SDK directory\lib\SimConnect\managed, you should see 2 dlls. LockheedMartin.Prepar3D.SimConnect.dll and LockheedMartin.Prepar3D.SimConnect.Debug.dll. Did you place the LockheedMartin.Prepar3D.SimConnect.dll in the same directory as your final executable?
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun
User avatar
WarpD
Posts: 1469
Joined: Mon Feb 14, 2011 5:29 am

Re: Get Plane Coordinates of P3D

Post by WarpD »

Right... why are you importing the DLL and not using the LIB file?
Ed Wilson
Senior Developer
Mindstar Aviation
JB3DG
Posts: 609
Joined: Mon Jan 09, 2012 6:44 pm

Re: Get Plane Coordinates of P3D

Post by JB3DG »

C# doesn't use libs in the same way as C++. After all, managed code is rather different from native.
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun
User avatar
WarpD
Posts: 1469
Joined: Mon Feb 14, 2011 5:29 am

Re: Get Plane Coordinates of P3D

Post by WarpD »

Reminds me of VB... LOL

Since the OP hasn't responded... guess we assume all is well? :)
Ed Wilson
Senior Developer
Mindstar Aviation
JB3DG
Posts: 609
Joined: Mon Jan 09, 2012 6:44 pm

Re: Get Plane Coordinates of P3D

Post by JB3DG »

Either way he got the answer to his problem at the end of my first reply. And yes I would guess VB is quite similar to C#.
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun
User avatar
WarpD
Posts: 1469
Joined: Mon Feb 14, 2011 5:29 am

Re: Get Plane Coordinates of P3D

Post by WarpD »

Arcane note: Borland's Delphi was a response to Microsoft's VB back in the day... and C# is Microsoft's response to Borland's Delphi. Both Delphi and C# were created by the same guy.
Ed Wilson
Senior Developer
Mindstar Aviation
hkhoanguyen
Posts: 46
Joined: Sat Feb 21, 2015 8:45 am

Re: Get Plane Coordinates of P3D

Post by hkhoanguyen »

Hi Guys, Thanks a lot for your replies,

I managed to get the coordinates and display the plane on Google Map,

However, I have one question, of how to draw a line that follows the plane on google map ?

2nd question: how to draw a flight plan line from A to B on google map based on the list of waypoints we provide ?

as i'm new to this kind of development, it would be great for me if you guys have some ideas or links that I can look into.

Thanks,
JB3DG
Posts: 609
Joined: Mon Jan 09, 2012 6:44 pm

Re: Get Plane Coordinates of P3D

Post by JB3DG »

That you would best contact google for....I don't know of anyone here who has done that.
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun
hkhoanguyen
Posts: 46
Joined: Sat Feb 21, 2015 8:45 am

Re: Get Plane Coordinates of P3D

Post by hkhoanguyen »

Naruto-kun wrote: Mon Oct 23, 2017 2:58 pm That you would best contact google for....I don't know of anyone here who has done that.
There are many examples out there like fsxtracker.com or other moving map... I just still don't know how to implement that, any idea would help
Locked