Ejemplo n.º 1
0
static void SetValues(void) {
  int atype = 0;
  AIRSPACE_ALT* top = NULL;
  AIRSPACE_ALT* base = NULL;
  TCHAR *name = 0;
  WndProperty* wp;
  TCHAR buffer[80];
  TCHAR buffer2[80];
  bool inside = false;
  double range = 0.0;
  double bearing;

  if (index_area >=0) {
    atype = AirspaceArea[index_area].Type;
    top = &AirspaceArea[index_area].Top;
    base = &AirspaceArea[index_area].Base;
    name = AirspaceArea[index_area].Name;
    inside = InsideAirspaceArea(GPS_INFO.Longitude, GPS_INFO.Latitude, 
				index_area);
    range = 
      RangeAirspaceArea(GPS_INFO.Longitude, GPS_INFO.Latitude, 
			index_area, &bearing);
  }
  if (index_circle >=0) {
    atype = AirspaceCircle[index_circle].Type;
    top = &AirspaceCircle[index_circle].Top;
    base = &AirspaceCircle[index_circle].Base;
    name = AirspaceCircle[index_circle].Name;
    inside = InsideAirspaceCircle(GPS_INFO.Longitude, GPS_INFO.Latitude, 
				  index_circle);
    range = 
      RangeAirspaceCircle(GPS_INFO.Longitude, GPS_INFO.Latitude, 
			  index_circle);

    DistanceBearing(GPS_INFO.Latitude,
		    GPS_INFO.Longitude,
		    AirspaceCircle[index_circle].Latitude, 
		    AirspaceCircle[index_circle].Longitude,
		    NULL, &bearing);
    if (inside) {
      bearing = AngleLimit360(bearing+180);
    }
  }

  if (range<0) {
    range = -range;
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpName"));
  if (wp) {
    wp->SetText(name);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpType"));
  if (wp) {
    switch (atype) {
    case RESTRICT:
	// LKTOKEN  _@M565_ = "Restricted" 
      wp->SetText(gettext(TEXT("_@M565_"))); break;
    case PROHIBITED:
	// LKTOKEN  _@M537_ = "Prohibited" 
      wp->SetText(gettext(TEXT("_@M537_"))); break;
    case DANGER:
	// LKTOKEN  _@M213_ = "Danger Area" 
      wp->SetText(gettext(TEXT("_@M213_"))); break;
    case CLASSA:
      wp->SetText(TEXT("Class A")); break;
    case CLASSB:
      wp->SetText(TEXT("Class B")); break;
    case CLASSC:
      wp->SetText(TEXT("Class C")); break;
    case CLASSD:
      wp->SetText(TEXT("Class D")); break;
    case CLASSE:
      wp->SetText(TEXT("Class E")); break;
    case CLASSF:
      wp->SetText(TEXT("Class F")); break;
    case CLASSG:
      wp->SetText(TEXT("Class G")); break;
    case NOGLIDER:
	// LKTOKEN  _@M464_ = "No Glider" 
      wp->SetText(gettext(TEXT("_@M464_"))); break;
    case CTR:
      wp->SetText(TEXT("CTR")); break;
    case WAVE:
	// LKTOKEN  _@M794_ = "Wave" 
      wp->SetText(gettext(TEXT("_@M794_"))); break;
    default:
	// LKTOKEN  _@M765_ = "Unknown" 
      wp->SetText(gettext(TEXT("_@M765_")));
    }
    wp->RefreshDisplay();
  }
  
  wp = (WndProperty*)wf->FindByName(TEXT("prpTop"));
  if (wp) {
    switch (top->Base){
    case abUndef:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, TEXT("%.0f[m] %.0f[ft] [?]"), 
		  (top->Altitude), 
		  (top->Altitude*TOFEET));
      } else {
	_stprintf(buffer, TEXT("%.0f ft [?]"), 
		  (top->Altitude*TOFEET));
      }
      break;
    case abMSL:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, TEXT("%.0f[m] %.0f[ft] MSL"), 
		  top->Altitude, top->Altitude*TOFEET);
      } else {
	_stprintf(buffer, TEXT("%.0f ft MSL"), 
		  top->Altitude*TOFEET);
      }
      break;
    case abAGL:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, TEXT("%.0f[m] %.0f[ft] AGL"), 
		  top->AGL, top->AGL*TOFEET);
      } else {
	_stprintf(buffer, TEXT("%.0f ft AGL"), 
		  top->AGL*TOFEET);
      }
      break;
    case abFL:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, TEXT("FL%.0f (%.0f[m] %.0f[ft])"), 
		  top->FL, FLAltRounded(top->Altitude), 
		  FLAltRounded(top->Altitude*TOFEET));
      } else {
	_stprintf(buffer, TEXT("FL%.0f (%.0f ft)"), 
		  top->FL, FLAltRounded(top->Altitude*TOFEET));
      }
      break;
    }
    wp->SetText(buffer);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpBase"));
  if (wp) {
    switch (base->Base){
    case abUndef:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, TEXT("%.0f[m] %.0f[ft] [?]"), 
		  base->Altitude, base->Altitude*TOFEET);
      } else {
	_stprintf(buffer, TEXT("%.0f ft [?]"), 
		  base->Altitude*TOFEET);
      }
      break;
    case abMSL:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, TEXT("%.0f[m] %.0f[ft] MSL"), 
		  base->Altitude, base->Altitude*TOFEET);
      } else {
	_stprintf(buffer, TEXT("%.0f ft MSL"), 
		  base->Altitude*TOFEET);
      }
      break;
    case abAGL:
      if (base->Altitude == 0) {
        _stprintf(buffer, TEXT("SFC"));
      } else {
	if (Units::GetUserAltitudeUnit() == unMeter) {
	  _stprintf(buffer, TEXT("%.0f[m] %.0f[ft] AGL"), 
		    base->AGL, base->AGL*TOFEET);
	} else {
	  _stprintf(buffer, TEXT("%.0f ft AGL"), 
		    base->AGL*TOFEET);
	}
      }
      break;
    case abFL:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, TEXT("FL %.0f (%.0f[m] %.0f[ft])"), 
		  base->FL, FLAltRounded(base->Altitude), 
		  FLAltRounded(base->Altitude*TOFEET));
      } else {
	_stprintf(buffer, TEXT("FL%.0f (%.0f ft)"), 
		  base->FL, FLAltRounded(base->Altitude*TOFEET));
      }
      break;
    }
    wp->SetText(buffer);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpRange"));
  if (wp) {
    if (inside) {
	// LKTOKEN  _@M359_ = "Inside" 
      wp->SetCaption(gettext(TEXT("_@M359_")));
    }
    Units::FormatUserDistance(range, buffer, 20);
    _stprintf(buffer2, TEXT(" %d")TEXT(DEG), iround(bearing));
    _tcscat(buffer, buffer2);
    wp->SetText(buffer);
    wp->RefreshDisplay();
  }
}
Ejemplo n.º 2
0
static void SetValues(void) {
  int atype = 0;
  AIRSPACE_ALT* top = NULL;
  AIRSPACE_ALT* base = NULL;
  TCHAR *name = 0;
  WndProperty* wp;
  TCHAR buffer[80];
  TCHAR buffer2[80];
  bool inside = false;
  double range = 0.0;
  double bearing;

  if (index_area >=0) {
    AIRSPACE_AREA &area = airspace_database.AirspaceArea[index_area];
    MapWindow &map_window = XCSoarInterface::main_window.map;

    atype = area.Type;
    top = &area.Top;
    base = &area.Base;
    name = area.Name;
    inside = airspace_database.InsideArea(XCSoarInterface::Basic().Location,
                                          index_area);
    range = airspace_database.RangeArea(XCSoarInterface::Basic().Location,
                                        index_area, &bearing,
                                        map_window);
  }

  if (index_circle >=0) {
    AIRSPACE_CIRCLE &circle = airspace_database.AirspaceCircle[index_circle];

    atype = circle.Type;
    top = &circle.Top;
    base = &circle.Base;
    name = circle.Name;
    inside = airspace_database.InsideCircle(XCSoarInterface::Basic().Location,
                                            index_circle);
    range = airspace_database.CircleDistance(XCSoarInterface::Basic().Location,
                                             index_circle);

    DistanceBearing(XCSoarInterface::Basic().Location, circle.Location,
		    NULL, &bearing);
    if (inside) {
      bearing = AngleLimit360(bearing+180);
    }
  }

  if (range<0) {
    range = -range;
  }

  wp = (WndProperty*)wf->FindByName(_T("prpName"));
  if (wp) {
    wp->SetText(name);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpType"));
  if (wp) {
    switch (atype) {
    case RESTRICT:
      wp->SetText(gettext(_T("Restricted"))); break;
    case PROHIBITED:
      wp->SetText(gettext(_T("Prohibited"))); break;
    case DANGER:
      wp->SetText(gettext(_T("Danger Area"))); break;
    case CLASSA:
      wp->SetText(gettext(_T("Class A"))); break;
    case CLASSB:
      wp->SetText(gettext(_T("Class B"))); break;
    case CLASSC:
      wp->SetText(gettext(_T("Class C"))); break;
    case CLASSD:
      wp->SetText(gettext(_T("Class D"))); break;
    case CLASSE:
      wp->SetText(gettext(_T("Class E"))); break;
    case CLASSF:
      wp->SetText(gettext(_T("Class F"))); break;
    case NOGLIDER:
      wp->SetText(gettext(_T("No Glider"))); break;
    case CTR:
      wp->SetText(gettext(_T("CTR"))); break;
    case WAVE:
      wp->SetText(gettext(_T("Wave"))); break;
    default:
      wp->SetText(gettext(_T("Unknown")));
    }
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpTop"));
  if (wp) {
    switch (top->Base){
    case abUndef:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, _T("%.0f[m] %.0f[ft] [?]"),
		  (top->Altitude),
		  (top->Altitude*TOFEET));
      } else {
	_stprintf(buffer, _T("%.0f ft [?]"),
		  (top->Altitude*TOFEET));
      }
      break;
    case abMSL:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, _T("%.0f[m] %.0f[ft] MSL"),
		  top->Altitude, top->Altitude*TOFEET);
      } else {
	_stprintf(buffer, _T("%.0f ft MSL"),
		  top->Altitude*TOFEET);
      }
      break;
    case abAGL:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, _T("%.0f[m] %.0f[ft] AGL"),
		  top->AGL, top->AGL*TOFEET);
      } else {
	_stprintf(buffer, _T("%.0f ft AGL"),
		  top->AGL*TOFEET);
      }
      break;
    case abFL:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, _T("FL%.0f (%.0f[m] %.0f[ft])"),
		  top->FL, FLAltRounded(top->Altitude),
		  FLAltRounded(top->Altitude*TOFEET));
      } else {
	_stprintf(buffer, _T("FL%.0f (%.0f ft)"),
		  top->FL, FLAltRounded(top->Altitude*TOFEET));
      }
      break;
    }
    wp->SetText(buffer);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpBase"));
  if (wp) {
    switch (base->Base){
    case abUndef:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, _T("%.0f[m] %.0f[ft] [?]"),
		  base->Altitude, base->Altitude*TOFEET);
      } else {
	_stprintf(buffer, _T("%.0f ft [?]"),
		  base->Altitude*TOFEET);
      }
      break;
    case abMSL:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, _T("%.0f[m] %.0f[ft] MSL"),
		  base->Altitude, base->Altitude*TOFEET);
      } else {
	_stprintf(buffer, _T("%.0f ft MSL"),
		  base->Altitude*TOFEET);
      }
      break;
    case abAGL:
      if (base->Altitude == 0) {
        _stprintf(buffer, _T("SFC"));
      } else {
	if (Units::GetUserAltitudeUnit() == unMeter) {
	  _stprintf(buffer, _T("%.0f[m] %.0f[ft] AGL"),
		    base->AGL, base->AGL*TOFEET);
	} else {
	  _stprintf(buffer, _T("%.0f ft AGL"),
		    base->AGL*TOFEET);
	}
      }
      break;
    case abFL:
      if (Units::GetUserAltitudeUnit() == unMeter) {
	_stprintf(buffer, _T("FL %.0f (%.0f[m] %.0f[ft])"),
		  base->FL, FLAltRounded(base->Altitude),
		  FLAltRounded(base->Altitude*TOFEET));
      } else {
	_stprintf(buffer, _T("FL%.0f (%.0f ft)"),
		  base->FL, FLAltRounded(base->Altitude*TOFEET));
      }
      break;
    }
    wp->SetText(buffer);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpRange"));
  if (wp) {
    if (inside) {
      wp->SetCaption(gettext(_T("Inside")));
    }
    Units::FormatUserDistance(range, buffer, 20);
    _stprintf(buffer2, _T(" %d")_T(DEG), iround(bearing));
    _tcscat(buffer, buffer2);
    wp->SetText(buffer);
    wp->RefreshDisplay();
  }
}