//List<Anomalies.Anomaly> anomaliesList = new List<Anomalies.Anomaly>(); public void SetClosestAnomaly() { // this is run on establishing landing spot (to avoid expensive constant foreach loops SetRoverLocation(); // (update rover location) closestAnomaly = Anomalies.Instance.ClosestAnomaly(Vessel, Vessel.mainBody.bodyName); }
public void setClosestAnomaly(string bodyName) { // this is run on establishing landing spot (to avoid expensive constant foreach loops setRoverLocation(); // (update rover location) double distanceClosest = 0; double distanceCheck = 0; if (Anomalies.Instance.hasAnomalies(bodyName)) { anomaliesList = Anomalies.Instance.getAnomalies(bodyName); closestAnomaly = anomaliesList[0]; // set initial // check and find closest anomaly int i = 0; foreach (Anomalies.Anomaly anomaly in anomaliesList) { distanceClosest = getDistanceBetweenTwoPoints(location, closestAnomaly.location); distanceCheck = getDistanceBetweenTwoPoints(location, anomaly.location); //Debug.Log("========" + i + "========"); //Debug.Log("distanceClosest: " + distanceClosest); //Debug.Log("distanceCheck: " + distanceCheck); //Debug.Log("Current lat/long: " + location.latitude + "/" + location.longitude); //Debug.Log("Closest Anomaly lat/long: " + closestAnomaly.location.latitude + "/" + closestAnomaly.location.longitude); //Debug.Log("Check Anomaly lat/long: " + anomaly.location.latitude + "/" + anomaly.location.longitude); //Debug.Log("==========<END>=========="); if (distanceCheck < distanceClosest) { closestAnomaly = anomaly; } i++; } distanceClosest = getDistanceBetweenTwoPoints(location, closestAnomaly.location); Debug.Log("======= RS: closest anomaly details ======="); Debug.Log("long/lat: " + closestAnomaly.location.longitude + "/" + closestAnomaly.location.latitude); Debug.Log("instantaneous distance: " + getDistanceBetweenTwoPoints(location, closestAnomaly.location)); Debug.Log("id: " + closestAnomaly.id); Debug.Log("name: " + closestAnomaly.name); Debug.Log("=== RS: closest anomaly details <<END>>===="); } }