short_way.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * \file short_way.c
  3. *
  4. * \brief GIS Library - Shortest path functions.
  5. *
  6. * (C) 2001-2008 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public License
  9. * (>=v2). Read the file COPYING that comes with GRASS for details.
  10. *
  11. * \author GRASS GIS Development Team
  12. *
  13. * \date 1999-2008
  14. */
  15. #include <grass/gis.h>
  16. /**
  17. * \brief Shortest way between two eastings.
  18. *
  19. * For lat-lon projection (<i>PROJECTION_LL</i>), <b>east1</b>,
  20. * <b>east2</b> are changed so that they are no more than 180 degrees
  21. * apart. Their true locations are not changed. For all other
  22. * projections, this function does nothing.
  23. *
  24. * \param[in] east1 east (x) coordinate of first point
  25. * \param[in] east2 east (x) coordinate of second point
  26. * \return always returns 0
  27. */
  28. int G_shortest_way(double *east1, double *east2)
  29. {
  30. if (G_projection() == PROJECTION_LL) {
  31. if (*east1 > *east2)
  32. while ((*east1 - *east2) > 180)
  33. *east2 += 360;
  34. else if (*east2 > *east1)
  35. while ((*east2 - *east1) > 180)
  36. *east1 += 360;
  37. }
  38. return 0;
  39. }