growing.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "growing.h"
  5. void P_Aux_to_Coor(struct Map_info *In, struct Map_info *Out,
  6. dbDriver * driver, FILE * fsite)
  7. {
  8. int cont = 0;
  9. int more, ltype, line_num, ID_type, Interp_type;
  10. double quotaZ;
  11. struct line_pnts *point;
  12. struct line_cats *cat;
  13. dbTable *table;
  14. dbColumn *ID_column, *Interp_column;
  15. dbValue *ID_value, *Interp_value;
  16. dbCursor cursor;
  17. dbString sql;
  18. point = Vect_new_line_struct();
  19. cat = Vect_new_cats_struct();
  20. db_init_string(&sql);
  21. db_zero_string(&sql);
  22. db_append_string(&sql,
  23. "select ID, sum(Interp) from Auxiliar_table group by ID");
  24. db_open_select_cursor(driver, &sql, &cursor, DB_SEQUENTIAL);
  25. while (db_fetch(&cursor, DB_NEXT, &more) == DB_OK && more) {
  26. cont++;
  27. table = db_get_cursor_table(&cursor);
  28. ID_column = db_get_table_column(table, 0);
  29. Interp_column = db_get_table_column(table, 1);
  30. ID_type = db_sqltype_to_Ctype(db_get_column_sqltype(ID_column));
  31. Interp_type =
  32. db_sqltype_to_Ctype(db_get_column_sqltype(Interp_column));
  33. if (ID_type == DB_C_TYPE_INT)
  34. ID_value = db_get_column_value(ID_column);
  35. else
  36. continue;
  37. if (Interp_type == DB_C_TYPE_DOUBLE)
  38. Interp_value = db_get_column_value(Interp_column);
  39. else
  40. continue;
  41. line_num = db_get_value_int(ID_value);
  42. quotaZ = db_get_value_double(Interp_value);
  43. ltype = Vect_read_line(In, point, cat, line_num);
  44. if (!(ltype & GV_POINT))
  45. continue;
  46. point->z[0] = quotaZ;
  47. Vect_write_line(Out, ltype, point, cat);
  48. }
  49. return;
  50. }