private static GPSEncoder GetInstance() { if (_singleton == null) { _singleton = new GPSEncoder(); } return(_singleton); }
public static Vector2 GetLatitudeLongitudeFromPosition(this Transform transform, Vector3 point) { var tile = transform.GetComponent <ITile>(); GPSEncoder.SetLocalOrigin(tile.Center); var x = -point.x / MapboxConvenience.Instance.TileScale * tile.TileScaleInMeters; var y = -point.z / MapboxConvenience.Instance.TileScale * tile.TileScaleInMeters; return(GPSEncoder.USCToGPS(new Vector3(x, 0, y))); }
public static Vector3 GetPositionFromGeoCoordinate(this Transform transform, GeoCoordinate geoCoordinate) { var tile = transform.GetComponent <ITile>(); GPSEncoder.SetLocalOrigin(tile.Center); var position = GPSEncoder.GPSToUCS(new Vector2((float)geoCoordinate.Latitude, (float)geoCoordinate.Longitude)) / tile.TileScaleInMeters; position.x = -position.x * MapboxConvenience.Instance.TileScale; position.z = -position.z * MapboxConvenience.Instance.TileScale; return(position); }
public static Vector3 GetPositionFromLatitudeLongitude(this Transform transform, float latitude, float longitude) { var tile = transform.GetComponent <ITile>(); GPSEncoder.SetLocalOrigin(tile.Center); var position = GPSEncoder.GPSToUCS(new Vector2(latitude, longitude)) / tile.TileScaleInMeters; // FIXME: this should not be coupled to Mapbox convenience! position.x = -position.x * MapboxConvenience.Instance.TileScale; position.z = -position.z * MapboxConvenience.Instance.TileScale; return(position); }