示例#1
0
 private static GPSEncoder GetInstance()
 {
     if (_singleton == null)
     {
         _singleton = new GPSEncoder();
     }
     return(_singleton);
 }
示例#2
0
        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)));
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }