grid_decimation.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /****************************************************************************
  2. *
  3. * MODULE: v.decimate
  4. * AUTHOR(S): Vaclav Petras
  5. * PURPOSE: Reduce the number of points in a vector map
  6. * COPYRIGHT: (C) 2015 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public
  9. * License (>=v2). Read the COPYING file that comes with GRASS
  10. * for details.
  11. *
  12. *****************************************************************************/
  13. #ifndef GRASS_GRID_DECIMATION_H
  14. #define GRASS_GRID_DECIMATION_H
  15. #include <grass/gis.h>
  16. struct DecimationPoint
  17. {
  18. int cat;
  19. double x;
  20. double y;
  21. double z;
  22. };
  23. struct GridDecimation
  24. {
  25. struct DecimationPoint ***grid_points;
  26. size_t *grid_sizes;
  27. int rows;
  28. int cols;
  29. int max_points;
  30. double minx;
  31. double maxx;
  32. double miny;
  33. double maxy;
  34. double ns_res;
  35. double ew_res;
  36. int (*if_add_point) (struct DecimationPoint * point, void *point_data,
  37. struct DecimationPoint ** point_list, size_t npoints,
  38. void *context);
  39. void (*on_add_point) (struct DecimationPoint * point, void *point_data, void *context);
  40. void *if_context;
  41. void *on_context;
  42. };
  43. /* max size: rows * cols < max of size_t (using 1D array) */
  44. void grid_decimation_create(struct GridDecimation *grid_decimation,
  45. size_t rows, size_t cols);
  46. void grid_decimation_create_from_region(struct GridDecimation
  47. *grid_decimation,
  48. struct Cell_head *region);
  49. /* TODO: possible use (also?) Cell_head as input or storage */
  50. void grid_decimation_set_region(struct GridDecimation *grid_decimation,
  51. double minx, double maxx, double miny,
  52. double maxy, double ns_res, double ew_res);
  53. void grid_decimation_create_list_with_point(struct GridDecimation
  54. *grid_decimation, size_t index,
  55. struct DecimationPoint *point,
  56. size_t npoints);
  57. void grid_decimation_add_point_to_list(struct GridDecimation *grid_decimation,
  58. size_t index,
  59. struct DecimationPoint *point,
  60. size_t npoints);
  61. void grid_decimation_try_add_point(struct GridDecimation *grid_decimation,
  62. int cat, double x, double y, double z, void *point_data);
  63. void grid_decimation_destroy(struct GridDecimation *grid_decimation);
  64. #endif /* GRASS_GRID_DECIMATION_H */