cp.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <grass/glocale.h>
  4. #include "global.h"
  5. int get_control_points(char *group, int order /* THIS HAS BEEN ADDED WITH THE CRS MODIFICATIONS */
  6. )
  7. {
  8. char msg[200];
  9. if (!I_get_control_points(group, &cp))
  10. exit(0);
  11. sprintf(msg, _("Control Point file for group <%s@%s> - "),
  12. group, G_mapset());
  13. if (order == 0) {
  14. switch (I_compute_georef_equations_tps(&cp, &E12_t, &N12_t, &E21_t, &N21_t)) {
  15. case 0:
  16. sprintf(&msg[strlen(msg)],
  17. _("Not enough active control points for thin plate spline."));
  18. break;
  19. case -1:
  20. strcat(msg, _("Poorly placed control points."));
  21. strcat(msg, _(" Can not generate the transformation equation."));
  22. break;
  23. case -2:
  24. strcat(msg, _("Not enough memory to solve for transformation equation"));
  25. break;
  26. case -3:
  27. strcat(msg, _("Invalid order"));
  28. break;
  29. default:
  30. /* COMMENTED OUT WHEN SUPPORT FOR 3rd ORDER WAS ADDED BY 'CRS'
  31. E12a = E12[0]; E12b = E12[1]; E12c = E12[2];
  32. N12a = N12[0]; N12b = N12[1]; N12c = N12[2];
  33. E21a = E21[0]; E21b = E21[1]; E21c = E21[2];
  34. N21a = N21[0]; N21b = N21[1]; N21c = N21[2];
  35. */
  36. return 1;
  37. }
  38. }
  39. else {
  40. switch (I_compute_georef_equations(&cp, E12, N12, E21, N21, order)) {
  41. case 0:
  42. sprintf(&msg[strlen(msg)],
  43. _("Not enough active control points for current order, %d are required."),
  44. (order + 1) * (order + 2) / 2);
  45. break;
  46. case -1:
  47. strcat(msg, _("Poorly placed control points."));
  48. strcat(msg, _(" Can not generate the transformation equation."));
  49. break;
  50. case -2:
  51. strcat(msg, _("Not enough memory to solve for transformation equation"));
  52. break;
  53. case -3:
  54. strcat(msg, _("Invalid order"));
  55. break;
  56. default:
  57. /* COMMENTED OUT WHEN SUPPORT FOR 3rd ORDER WAS ADDED BY 'CRS'
  58. E12a = E12[0]; E12b = E12[1]; E12c = E12[2];
  59. N12a = N12[0]; N12b = N12[1]; N12c = N12[2];
  60. E21a = E21[0]; E21b = E21[1]; E21c = E21[2];
  61. N21a = N21[0]; N21b = N21[1]; N21c = N21[2];
  62. */
  63. return 1;
  64. }
  65. }
  66. G_fatal_error("%s", msg);
  67. return 0; /* G_fatal_error() calls exit() */
  68. }