using System; using UnityEngine; [Serializable] public class LatLong_Conversion : MonoBehaviour { public global_settings_tc global_script; public latlong_class latlong_center; public latlong_class[] latlong; public Vector2 offset; public LatLong_Conversion() { latlong_center = new latlong_class(); offset = new Vector2(0f, -27f); } public virtual void Start() { int num = 0; latlong[2].latitude = 49.34544372558594; latlong[2].longitude = -119.57958221435547; int i = 0; latlong_class[] array = latlong; for (int length = array.Length; i < length; i++) { Vector2 vector = calc_position(array[i].latitude, array[i].longitude); GameObject gameObject = GameObject.CreatePrimitive(PrimitiveType.Cube); gameObject.transform.position = new Vector3(vector.x, 0f, vector.y); Debug.Log(calc_latlong(gameObject.transform.position).x + " : " + calc_latlong(gameObject.transform.position).y); gameObject.name = "Test point " + num; num++; } } public virtual Vector2 calc_latlong(Vector3 pos) { map_pixel_class map_pixel_class2 = new map_pixel_class(); map_pixel_class map_pixel_class3 = global_script.latlong_to_pixel2(latlong_center, 19.0); double num = global_script.calc_latlong_area_resolution(latlong_center, 19.0); map_pixel_class2.x = (double)(pos.x - offset.x) / num + map_pixel_class3.x; map_pixel_class2.y = (double)(0f - (pos.z - offset.y)) / num + map_pixel_class3.y; latlong_class latlong_class2 = global_script.pixel_to_latlong2(map_pixel_class2, 19.0); return new Vector2((float)latlong_class2.longitude, (float)latlong_class2.latitude); } public virtual Vector2 calc_position(double lat, double lon) { latlong_class latlong_class2 = new latlong_class(lat, lon); Vector2 vector = default(Vector2); map_pixel_class map_pixel_class2 = global_script.latlong_to_pixel2(latlong_class2, 19.0); map_pixel_class map_pixel_class3 = global_script.latlong_to_pixel2(latlong_center, 19.0); double num = global_script.calc_latlong_area_resolution(latlong_center, 19.0); vector.x = (float)((map_pixel_class2.x - map_pixel_class3.x) * num); vector.y = (float)((0.0 - map_pixel_class2.y + map_pixel_class3.y) * num); return vector + offset; } public virtual void Main() { } }