get_coor.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. ****************************************************************************
  3. *
  4. * MODULE: v.transform
  5. * AUTHOR(S): See other files as well...
  6. * Eric G. Miller <egm2@jps.net>
  7. * PURPOSE: Read all the registration (map) coordinates in from the file
  8. * COPYRIGHT: (C) 2002 by the GRASS Development Team
  9. *
  10. * This program is free software under the GNU General Public
  11. * License (>=v2). Read the file COPYING that comes with GRASS
  12. * for details.
  13. *
  14. *****************************************************************************/
  15. #include <stdio.h>
  16. #include "trans.h"
  17. #include <grass/gis.h>
  18. #include <grass/glocale.h>
  19. int get_coor_from_file(FILE * fp)
  20. {
  21. int i;
  22. char buff[128];
  23. for (i = 0; i < MAX_COOR; i++) {
  24. if (fgets(buff, sizeof(buff), fp) == NULL)
  25. break;
  26. if (sscanf(buff, "%lf %lf %lf %lf", &ax[i], &ay[i], &bx[i], &by[i]) !=
  27. 4) {
  28. /* comment or illegal line found */
  29. if (!buff[0] == '#')
  30. G_fatal_error(_("Reading coordinates from file."));
  31. else
  32. i--; /* just comment found */
  33. }
  34. use[i] = 1;
  35. } /* for (i) */
  36. return (i);
  37. } /* get_coor_from_file () */