Board index FlightGear Development

how to get the longitude and latitude ?

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

how to get the longitude and latitude ?

Postby skywalker » Thu Jun 21, 2012 12:25 pm

I tried to get them like this:

FlightProperties * fdm=new FlightProperties ;
float lon=fdm->get_Longitude()*SGD_DEGREFS_TO_RADIANS;
float lat=fdm->get_Latitude()*SGD_DEGREFS_TO_RADIANS;


while I can't get the lon,and lat. could anybody help me ? thanks a lot!!
skywalker
 
Posts: 5
Joined: Thu Jun 21, 2012 9:18 am

Re: how to get the longitude and latitude ?

Postby Hooray » Thu Jun 21, 2012 3:51 pm

I think you need to provide a little more background information.
Otherwise, just getting the current lat/lon is as simple as using fgGetDouble("/position/latitude-deg"); and fgGetDouble("/position/longitude-deg");
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: how to get the longitude and latitude ?

Postby skywalker » Fri Jun 22, 2012 3:10 am

thanks for your reply! I want to draw my own HUD, I need to know the current lat/lon when the plane is flying~ . I will try your method~ thanks for your help~ :P
Last edited by Gijs on Fri Jun 22, 2012 8:48 am, edited 1 time in total.
Reason: No you useless quoting please
skywalker
 
Posts: 5
Joined: Thu Jun 21, 2012 9:18 am

Re: how to get the longitude and latitude ?

Postby skywalker » Fri Jun 22, 2012 12:40 pm

Hooray wrote in Thu Jun 21, 2012 3:51 pm:I think you need to provide a little more background information.
Otherwise, just getting the current lat/lon is as simple as using fgGetDouble("/position/latitude-deg"); and fgGetDouble("/position/longitude-deg");

I have tried your way,but what I have got are constant. I want to get the quantity,which will change as the plane flying~
waiting for your reply~ thanks!
skywalker
 
Posts: 5
Joined: Thu Jun 21, 2012 9:18 am

Re: how to get the longitude and latitude ?

Postby Hooray » Fri Jun 22, 2012 4:16 pm

post your code (or use the devel mailing list)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: how to get the longitude and latitude ?

Postby Gijs » Fri Jun 22, 2012 5:14 pm

Do you really want to design a new HUD system, or just edit the way the HUD looks and the data it visualises? For the later you don't need to edit source. Check Docs/README.hud for more info on making a custom HUD.
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9549
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: how to get the longitude and latitude ?

Postby Hooray » Fri Jun 22, 2012 6:11 pm

He posted C++ code, and he said he wanted to draw a custom HUD, so he'll probably want to use C++.
On the other hand, the new canvas system could be another option: http://wiki.flightgear.org/Canvas_Properties
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: how to get the longitude and latitude ?

Postby skywalker » Sun Jun 24, 2012 12:35 pm

thanks for your replies~

this is part of my code:

HUD_my.cxx

... ....
_longitude(fgGetDouble("/position/longitude-deg"));
_latitude(fgGetDouble("/position/latitude-deg"));
... ...
fromwp_lon=_longitude;
fromwp_lat= _latitude;
towp_lon=100.111111111;
towp_lat=50.111111111;
dis= towp_lat-fromwp_lat;
... ...
//*** it will draw a line in the HUD ***
glBegin(GL_LINE_STRIP);
glVertext2f(_x,_y);
glVertext2f(_x+dis*10,_y);
glEnd();
... ...



I think the length of the line will modify when the plane is flying,because the dis is changing;

while the line I get is not change any more~~
skywalker
 
Posts: 5
Joined: Thu Jun 21, 2012 9:18 am

Re: how to get the longitude and latitude ?

Postby Hooray » Sun Jun 24, 2012 3:52 pm

you need to post a complete, sensible, snippet of your code - such as a whole function (i.e. SGSubsystem::update()) or at least the loop updating your HUD.
The code you have posted is far too incomplete to provide any useful feedback in my opinion. There are too many factors here.
Obviously, you need to update your HUD continuously, i.e. within the update() method of your subsystem.

Also, when you post your code, please use BB-code code tags - or use a pastebin like www.codepad.org
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: how to get the longitude and latitude ?

Postby skywalker » Tue Jun 26, 2012 8:33 am

Hooray:
Thank you!
I have resolved my problem.
Some of the code is not allowed to given out,I am sorry ~. Thanks for all your replies,wishing the BBS get better and better~
:)
skywalker
 
Posts: 5
Joined: Thu Jun 21, 2012 9:18 am


Return to Development

Who is online

Users browsing this forum: No registered users and 8 guests