Пример #1
0
    public static GeoPointMercator ToMercator(this GeoPointWGS84 geoPoint)
    {
        GeoPointMercator mercator = new GeoPointMercator(_transformationFromWGS84ToMercator.MathTransform.Transform(geoPoint.ToArray()))
        {
            altitude = geoPoint.altitude
        };

        return(mercator);
    }
Пример #2
0
    public static GeoPointWGS84 ToWGS84(this GeoPointMercator geoPoint)
    {
        GeoPointWGS84 wgs84 = new GeoPointWGS84(_transformationFromMercatorToWGS84.MathTransform.Transform(geoPoint.ToArray()))
        {
            altitude = geoPoint.altitude
        };

        return(wgs84);
    }
Пример #3
0
    public static GeoPointUTM ToUTM(this GeoPointMercator geoPoint)
    {
        GeoPointUTM utm = new GeoPointUTM(_transformationFromMercatorToUTM.MathTransform.Transform(geoPoint.ToArray()))
        {
            altitude = geoPoint.altitude
        };

        return(utm);
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        if (_test)
        {
            GeoPointUTM coordinatesUtm = _testPoint.transform.position.ToUTM();
            Debug.Log("Test point - UTM: " + coordinatesUtm);
            GeoPointWGS84 wgs84 = coordinatesUtm.ToWGS84();
            Debug.Log("Test point - WGS84: " + wgs84);
            GeoPointMercator utm = coordinatesUtm.ToMercator();
            Debug.Log("Test point - Mercator: " + utm);

            _test = false;
        }
        if (_testCoord)
        {
            GameObject point = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            point.transform.position = _wgsPointToTest.ToUTM().ToUnity();
            _testCoord = false;
        }
        if (_testDistance)
        {
            Debug.Log(Vector3.Distance(_testDistancePointA.position, _testDistancePointB.position) + "meters");
            _testDistance = false;
        }

        if (_testOrientation)
        {
            transform.LookAt(_testOrientationPoint);
            _testOrientation = false;
        }

        if (_testDistancePoint)
        {
            GameObject point = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            point.transform.position = transform.position + transform.forward * _distance;
            _testDistancePoint       = false;
        }

        if (_moveToDistance)
        {
            Ray        ray = new Ray(transform.position, transform.forward);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, float.PositiveInfinity))
            {
                float offset = hit.distance - _moveDistance;
                transform.position = transform.position + transform.forward * offset;
            }
            _moveToDistance = false;
        }

        Debug.DrawRay(transform.position, transform.forward * 100);
    }