Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Yes that would be the easiest and fastest way if you know SQL.

 

Most people use text files, for example those produced by MakeRunways.exe by Pete Dowson. Text files are slower but people use them because they do not know how to use SQL databases.

 

Paul

MySQL I know well, so what exactly should the database from the airport:
ICAO Code, IATA Code and Coordinates?
 
George
Posted

 

MySQL I know well, so what exactly should the database from the airport:
ICAO Code, IATA Code and Coordinates?
 
George

 

 

Yes that's all you need to find the current airport. 

 

You would do something like this:

 

1. Find current player position

2. Work out the Lon, Lat coordinates of a box 5 NM around the player

3. Select the airports from the database that have coordinates within this box

 

You can use the FsLatLonPoint class in my DLL to help with getting the coordinates of the test box. See the UserGuide.pdf for more details on this class.

 

If you get more than 1 airport back you can measure the distance to each one and find the closest. You can use FsLatLonPoint for this also.

 

Paul

Posted (edited)

Yes that's all you need to find the current airport. 

 

You would do something like this:

 

1. Find current player position

2. Work out the Lon, Lat coordinates of a box 5 NM around the player

3. Select the airports from the database that have coordinates within this box

 

You can use the FsLatLonPoint class in my DLL to help with getting the coordinates of the test box. See the UserGuide.pdf for more details on this class.

 

If you get more than 1 airport back you can measure the distance to each one and find the closest. You can use FsLatLonPoint for this also.

 

Paul

Some questions!

1.Give me please  a sample code, how to do it!

2.How to add in DB coordinates of airport, in one field record the latitude and longitude once or each in its field?

3.What used offset this, and how to write it correctly?

if (previous_onGndFlag != current_onGndFlag)
{
  if (current_onGndFlag == 1)
  {
    // - save the data you need -
  }
  previous_onGndFlag = current_onGndFlag;       // update previous_onGndFlag
}
private Offset<short> gndFlag = new Offset<short>(0x0366); 

Does not work!

 

George

Edited by A320_Pilot
Posted

George,

 

 

1. Give me please  a sample code, how to do it!

 

 

I really don't have the time to do this. This would be long and complicated code. All I can do is describe the process. The UserGuide shows you how the fsLonLatPoint class is used. I don't have MySQL so I cannot write the code to access the database.

 

 

2. How to add in DB coordinates of airport, in one field record the latitude and longitude once or each in its field?

 

 

You need two fields, one for Longitude and one for Latitude so you can filter on them.

 

 

What used offset this, and how to write it correctly?

 

 

Even92LN gave you sample code. This just shows you how to do it. It's not code you can just paste into your application. If you cannot see from that code how to make it work then you need to learn programming or c# first. I have suggested this many times.

 

This forum is for helping people use my DLL. I cannot write your application for you one feature at a time, sorry. I just don't have the time. This isn't my Job, it's just a hobby. I will answer questions about my DLL, but not about how to write your application.

 

Paul

Posted

Paul, and if such offset, which considers the distance traveled in the simulator?

 

George

 

There is no such offset. You would need to keep track of this yourself. Every few seconds you should get the current position (lat/lon) and measure the distance from the previous position. Then add this to a total. I suggest adding another timer to the form and doing this every 10 seconds. The more often you track the position the more accurate the distance will be.

 

You can use the FsLonLatPoint class to measure the distance between two points in nm or km.  E.g.

 

distanceFlown += currentPoint.DistanceFromInNauticalMiles(previousPoint)

 

Paul 

Posted

Hi George,

 

Offset 0020 is the height of the ground (above sea level) directly under the aircraft.  So to get the altitude of the aircraft above the ground you subtract this from the altitude of the aircraft:

private Offset<long> altitude = new Offset<long>(0x0570);

private Offset<int> groundHeight = new Offset<int>(0x0020);

                //Altitude in meters

                double altitude_Metres = (double)altitude.Value / (65536d * 65536d);

                //---------------------------------------------------------------------------------//

                //Ground height in meters

                double groundHeight_Metres = (double)groundHeight.Value / (256d);

                //---------------------------------------------------------------------------------//

                //Altitude above ground in meters

                double altitudeAboveGround_Metres = altitude_Metres - groundHeight_Metres;                

                //---------------------------------------------------------------------------------//

                //Altitude above ground in feet

                double altitudeAboveGround_Feet = altitudeAboveGround_Metres * 3.28084d;

                this.lblAltitudeAboveGround.Text = altitudeAboveGround_Feet.ToString("F0");

Paul.

Posted

I do so here:
 

 //Altitude sea level in feets & meters
                double altM_s = (double)altitude_sea.Value / (65536d * 65536d);
                double altF_s = (double)altitude_sea.Value / (65536d * 65536d) * 3.28084d;
                this.alt_ur_sea_m.Text = altF_s.ToString("F0") + CLIENT_MSG0_RU
                    + " / " + altM_s.ToString("F0") + CLIENT_MSG1_RU;
                //---------------------------------------------------------------------------------//
                //Altitude ground level in feets & meters
                double altM_gr = (double)altitude_gr.Value / (65536d * 65536d);
                double altF_gr = (double)altitude_gr.Value / (65536d * 65536d) * 3.28084d;
                this.alt_ur_gr_m.Text = altF_gr.ToString("F0") + CLIENT_MSG0_RU
                    + " / " + altM_gr.ToString("F0") + CLIENT_MSG1_RU;
                //---------------------------------------------------------------------------------//

With your example is not very convenient ((((

 

George

Posted

George,

 

I posted the exact code you need to get this working. I showed you the offsets you need. I showed you how to convert the offset values into the correct units. I told you that you need to subtract the ground height from the altitude. I even wrote the code for the subtraction. I'm sorry that you find all of this inconvenient.

 

I'm not sure what else you expect me to do. I don't have the skill to guess what variable names and label names you would prefer. I'm just not that good a programmer.

 

Maybe you are trolling me, in which case you've had lots of fun wasting my time.

 

If you are sincere there you really need to learn to program before asking me for any more help. If you cannot take my working examples and put them into your code then I am wasting my time.

 

There are many excellent C# courses available on YouTube for free.

 

I cannot lock this thread but I will not be answering any more of your questions. [LOCKED IT FOR YOU! Pete]

 

Paul

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.