/// <summary> /// Takes a Vector3 and converts it to a WGS84 coordinate using the /// configured UTM projection. /// </summary> /// <param name="pos">A Unity world-space Vector3 coordinate</param> /// <returns>A WGS84 latitude/longitude coordinate</returns> public LatLng XYZ2LatLng(Vector3 pos) { pos = Map.transform.InverseTransformPoint(pos); var utm = new UtmCoord(pos.x + Origin.Easting, pos.z + Origin.Northing); var latlng = Projection.FromProjection(utm); latlng.Height = pos.y; return(latlng); }
private IEnumerator Setup() { SetupComplete = false; Map = FindObjectOfType <MapTileManager>(); while (!Map.SetupComplete) { yield return(null); } var proj = Map.Metadata.UtmProjection; Projection = new MapProjection(proj.Zone, proj.North); var point = Map.Metadata.Position - Map.Metadata.AnchorOffset; Origin = new UtmCoord(point.X, point.Y); SetupComplete = true; }