Example #1
0
    public void updateCoordinates(CoreLocationData data)
    {
        //float lat1 = data.latitude * Mathf.Rad2Deg;
        //float long1 = data.longitude * Mathf.Rad2Deg;
        //float distance = CoornidatesHelper.distanceFromDegreesToMeters(lat1,long1,CoornidatesHelper.getRandomLati(),CoornidatesHelper.getRandomLongi());
        //float distance = CoornidatesHelper.getRandomDistance();

        if(data != null){
            //Debug.Log("latitude: " + data.latitude + " longitude: " + data.longitude);
            double distance = CalculateHelper.calculateDistance(data.latitude, data.longitude, CoornidatesHelper.getRandomLati(),CoornidatesHelper.getRandomLongi());
            Debug.Log("+++++++distance: " + distance);
            this.transform.localScale = Vector3.one * (float)(1/distance);

            //float angle = CoornidatesHelper.degreesFromDegreesToMeters(lat1,long1,CoornidatesHelper.getRandomLati(),CoornidatesHelper.getRandomLongi());
            float angle = CoornidatesHelper.getRandomDegrees();
            Vector3 position = Quaternion.Euler(0,angle,0) * Vector3.forward;
            this.transform.position = position;

        }
        else
            Debug.Log("Data is null");
        //Debug.Log("Test native code: " + CalculateHelper.calculateDistance(41.59032, -87.47359, 41.6175, -87.48512));

        //CoreLocationBinding.stopUpdatingLocation();
        //Debug.Log("angle:"+ angle + " distance:"+ distance + "scale:" + this.transform.localScale + " position:" + this.transform.position);
    }
Example #2
0
    public void locationServicesDidUpdate( CoreLocationData locationData )
    {
        if(onUpdateCoordinates != null) {
            onUpdateCoordinates(locationData);

        }
    }
Example #3
0
    public void locationServicesDidUpdateLocation( string returnString )
    {
        // this is the location data for use in your game.  It is stored in a static ivar for easy access
        CoreLocationData locationData = CoreLocationData.locationDataFromString( returnString );
        CoreLocationManager.lastLocationData = locationData;

        // kick off the event
        if( locationServicesDidUpdate != null )
            locationServicesDidUpdate( locationData );
    }
    public void locationServicesDidUpdate( CoreLocationData locationData )
    {
        Debug.Log( "locationServicesDidUpdate event: " + locationData );

        myLatitude = locationData.latitude;
        myLongitude = locationData.longitude;

        latitudeText.text = myLatitude.ToString();
        longitudeText.text = myLongitude.ToString();
        float dy = (float)myLatitude - CLO_Latitude;
        float dx = (float)myLongitude - CLO_Longtitude;
        float angle = Mathf.Atan2(dx,dy) * Mathf.Rad2Deg;
        directionAngle = angle+180.0f;
    }
Example #5
0
    public void updateCoordinates(CoreLocationData data)
    {
        //float lat1 = data.latitude * Mathf.Rad2Deg;
        //float long1 = data.longitude * Mathf.Rad2Deg;
        //float distance = CoornidatesHelper.distanceFromDegreesToMeters(lat1,long1,CoornidatesHelper.getRandomLati(),CoornidatesHelper.getRandomLongi());
        //float distance = CoornidatesHelper.getRandomDistance();
        float distance;
        float angle;
        float latitudeTarget = CoornidatesHelper.getRandomLati();
        float longitudeTarget = CoornidatesHelper.getRandomLongi();
        //float latitudeTarget = 41.586135f;
        //float longitudeTarget = -87.474901f;
        if(data != null){

            double latitudeRef = data.latitude;
            double longitudeRef = data.longitude;

            distance = (float)CalculateHelper.calculateDistanceFromGPS(latitudeRef, longitudeRef, latitudeTarget,longitudeTarget);
            //Debug.Log("The distance of turbine and phone: " + distance);
            //float angle = CoornidatesHelper.degreesFromDegreesToMeters(lat1,long1,CoornidatesHelper.getRandomLati(),CoornidatesHelper.getRandomLongi());
            //float angle = CoornidatesHelper.getRandomDegrees();
            angle = (float)CalculateHelper.calculateDegreeFromGPS(latitudeRef, longitudeRef, latitudeTarget,longitudeTarget);

        }
        else {

            Debug.Log("No real GPS data of the phone");
            distance = CoornidatesHelper.getRandomDistance();
            angle = CoornidatesHelper.getRandomDegrees();
        }

        float realAngle = angle - (float)MainGUI.trueNorthDegree;
        if(realAngle < 0)
            realAngle = realAngle + 360.0f;

        Vector3 position = Quaternion.Euler(0, realAngle, 0) *Vector3.forward;

        this.transform.localScale = Vector3.one * (1/distance);
        //Vector3 position = Quaternion.Euler(0,angle,0) * Vector3.forward;
        this.transform.position = position;
        Debug.Log("Distance: " + distance + " Degree: " + angle + " Degree in Phone: " + realAngle);

        //Debug.Log("Test native code: " + CalculateHelper.calculateDistance(41.59032, -87.47359, 41.6175, -87.48512));
        //CoreLocationBinding.stopUpdatingLocation();
        //Debug.Log("angle:"+ angle + " distance:"+ distance + "scale:" + this.transform.localScale + " position:" + this.transform.position);
    }
Example #6
0
    public static CoreLocationData locationDataFromString( string locationString )
    {
        CoreLocationData locationData = new CoreLocationData();

        string[] parts = locationString.Split( '|' );
        if( parts.Length == 7 )
        {
            locationData.altitude = float.Parse( parts[0] );
            locationData.latitude = double.Parse( parts[1] );
            locationData.longitude = double.Parse( parts[2] );
            locationData.course = float.Parse( parts[3] );
            locationData.horizontalAccuracy = float.Parse( parts[4] );
            locationData.verticalAccuracy = float.Parse( parts[5] );
            locationData.speed = float.Parse( parts[6] );
        }

        return locationData;
    }