gpsdist.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2019 Clementine Computing LLC.
  3. *
  4. * This file is part of PopuFare.
  5. *
  6. * PopuFare is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * PopuFare is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with PopuFare. If not, see <https://www.gnu.org/licenses/>.
  18. *
  19. */
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <math.h>
  23. #include "../common/gpsmath.h"
  24. void usage(FILE *fp) {
  25. fprintf(fp, "\nusage:\n\n");
  26. fprintf(fp, " gpsdist <lat0> <lon0> <lat1> <lon1>");
  27. fprintf(fp, "\n\n");
  28. }
  29. int main(int argc, char **argv) {
  30. float lat0, lon0, lat1, lon1;
  31. float dist;
  32. if (argc < 5) {
  33. usage(stderr);
  34. exit(-1);
  35. }
  36. lat0 = atof(argv[1]);
  37. lon0 = atof(argv[2]);
  38. lat1 = atof(argv[3]);
  39. lon1 = atof(argv[4]);
  40. dist = GPS_Dist(lat0, lon0, lat1, lon1);
  41. printf("Distance = %f meters\n", dist);
  42. }