//OWN FUNCTIONS void GetCurrentPos() // Get position and add to lists { if (!Global.originSet && Global.tutorialComplete) { waitingGPS.SetActive(true); } //Vector2 currentPoint; dLocation dCurrentPoint; //Are you in Newcastle? if (minLon < GPS.Longitude && GPS.Longitude < maxLon && minLat < GPS.Latitude && GPS.Latitude < maxLat ) { //currentPoint=new Vector2(Input.location.lastData.longitude,Input.location.lastData.latitude); // Debug.Log("------------------Longitude: " + GPS.Longitude + " Latitude: " + GPS.Latitude); dCurrentPoint = new dLocation(GPS.Longitude, GPS.Latitude); } else { //TODO add out of bounds behaviour dCurrentPoint = new dLocation(GPS.Longitude, GPS.Latitude); //return; } if (dLocations.Count < 10) { dLocations.Add(dCurrentPoint); } else // If list contains 10 items { dLocations.RemoveAt(0); dLocations.Add(dCurrentPoint); coordsDif2 = dSquareDifference(); } if (dLocations.Count > 2) { if (inRange(dCurrentPoint, dLocations[dLocations.Count - 2])) { dCurrentLoc = dCurrentPoint; skipped = 1; } else { skipped++; } } //infoUI.text="Camera X: "+mainCam.transform.position.x+" Z: "+mainCam.transform.position.z+" base: "+rSolver.BaseRot+" / "+heading; }
// private GameObject locControl; // private LocationController lcScript; // Use this for initialization // void Start () { // locControl=GameObject.Find("locationController"); // lcScript=locControl.GetComponent<LocationController>(); // } // Update is called once per frame void Update() { if (Global.originSet) { lonLat = Global.dPlayerLatLon; worldPos = Conversions.lonLatToXZ(Global.dOrigin, lonLat); transform.localPosition = worldPos; } }
//public Text debugText; // Use this for initialization void Start() { setVisible(false); mainCam = Camera.main; lonLat = new dLocation(longitude, latitude); // //DeepLinkManager.Instance.LinkActivated += Instance_LinkActivated; Debug.Log("------------------Start Object Placment "); }
public static Vector3 lonLatToXZ(dLocation origin, dLocation point) { Vector3 xz = new Vector3(); Vector2 metersLonLat = metersPerLat(point.lat); xz.z = (float)(metersLonLat.y * (point.lat - origin.lat)); xz.y = -1; xz.x = (float)(metersLonLat.x * (point.lon - origin.lon)); return(xz); }
bool inRange(dLocation lonLat, dLocation lastLonLat, float range = 2.0f) { if (Conversions.coordsDistance(lastLonLat, lonLat) < range * skipped) { return(true); } else { return(false); } }
void setRegion(dLocation location) { double distance = Conversions.coordsDistance(location, Global.region1); if (distance < 150000) { Global.ActiveSet = 0; } else { Global.ActiveSet = 3; } }
public static double coordsDistance(dLocation point0, dLocation point1) { double distance = coordsDistance(point0.lat, point0.lon, point1.lat, point1.lon); return(distance); }
public static float bearing(dLocation point0, dLocation point1) { double heading = bearing(point0.lat, point0.lon, point1.lat, point1.lon); return((float)heading); }
void updateLatLng() { //GPS translated to xyz Vector3 xyz = new Vector3(); xyz.x = 0; xyz.y = 0; xyz.z = 0; float theta = rSolver.angle; if (dLocations.Count == 0) { return; } if (updateDisplay) { //Set origin if not set if (coordsDif2 < 0.001 && origin == new Vector2(0, 0)) { dOrigin = new dLocation(averageLon(), averageLat()); Global.dOrigin = dOrigin; origin = new Vector2((float)averageLon(), (float)averageLat()); Global.origin = origin; //xyz=Conversions.lonLatToXZ(origin,currentLoc); xyz = Conversions.lonLatToXZ(dOrigin, dCurrentLoc); dGpsLocs.Add(dOrigin); Global.dPlayerLatLon = dOrigin; cameraLocs.Add(mainCam.transform.position); //rotatedGPS.Add(xyz); rotatedGPS.Add(gpsMarker.transform.position); originSet = true; Global.originSet = true; //Debug.Log("origin= "+dOrigin.lon+","+dOrigin.lat); } // Debug.Log("------------------updateLatLng : originSet: " + originSet); //Update display if (originSet) { waitingGPS.SetActive(false); xyz = Conversions.lonLatToXZ(dOrigin, dCurrentLoc); if (dGpsLocs.Count < 150) { dGpsLocs.Add(dCurrentLoc); Global.dPlayerLatLon = dCurrentLoc; cameraLocs.Add(mainCam.transform.position); rotatedGPS.Add(gpsMarker.transform.position); } else { dGpsLocs.RemoveAt(0); cameraLocs.RemoveAt(0); rotatedGPS.RemoveAt(0); dGpsLocs.Add(dCurrentLoc); Global.dPlayerLatLon = dCurrentLoc; cameraLocs.Add(mainCam.transform.position); rotatedGPS.Add(gpsMarker.transform.position); } } setRegion(dCurrentLoc); } }