39 lines
936 B
C#
39 lines
936 B
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace GISTech.GISTerrainLoader
|
|
{
|
|
public class DistanceCalculation : MonoBehaviour
|
|
{
|
|
public AirplaneDemo Airplane;
|
|
|
|
private SimpleTerrainGenerator MyTerrainGenerator;
|
|
|
|
public Text UIDistance;
|
|
|
|
private void Start()
|
|
{
|
|
MyTerrainGenerator = GetComponent<SimpleTerrainGenerator>();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!(Airplane == null) && !(MyTerrainGenerator == null) && MyTerrainGenerator.TerrainGenerated)
|
|
{
|
|
DVector2 p = Airplane.GetAirPlaneLatLonElevation().ToDVector2();
|
|
DVector2 wayPointLatLon = Airplane.GetWayPointLatLon();
|
|
double num = Math.Round(GISTerrainLoaderGeoConversion.CalDistance(p, wayPointLatLon), 2);
|
|
if (num > 1.0)
|
|
{
|
|
UIDistance.text = "Distance to the next waypoint : " + num + " [Km]";
|
|
}
|
|
else
|
|
{
|
|
UIDistance.text = "Distance to the next waypoint : " + num * 1000.0 + " [m]";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|