units.c 694 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <string.h>
  2. #include "global.h"
  3. int conv_units()
  4. {
  5. int i, rad;
  6. double f, sq_f;
  7. rad = 0;
  8. f = G_meters_to_units_factor(options.units);
  9. sq_f = G_meters_to_units_factor_sq(options.units);
  10. if (options.units == U_RADIANS)
  11. rad = 1;
  12. switch (options.option) {
  13. case O_LENGTH:
  14. case O_PERIMETER:
  15. for (i = 0; i < vstat.rcat; i++)
  16. Values[i].d1 *= f;
  17. break;
  18. case O_AREA:
  19. for (i = 0; i < vstat.rcat; i++)
  20. Values[i].d1 *= sq_f;
  21. break;
  22. case O_AZIMUTH:
  23. if (rad == 0) {
  24. for (i = 0; i < vstat.rcat; i++) {
  25. if (Values[i].d1 > 0)
  26. Values[i].d1 = Values[i].d1*(180/M_PI);
  27. }
  28. }
  29. break;
  30. }
  31. return 0;
  32. }