point_binning.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * r.in.lidar projection-related functions
  3. *
  4. * Copyright 2011-2015 by Markus Metz, and The GRASS Development Team
  5. * Authors:
  6. * Markus Metz (r.in.lidar)
  7. * Vaclav Petras (move code to separate functions)
  8. *
  9. * This program is free software licensed under the GPL (>=v2).
  10. * Read the COPYING file that comes with GRASS for details.
  11. *
  12. */
  13. #ifndef __POINT_BINNING_H__
  14. #define __POINT_BINNING_H__
  15. #include <grass/raster.h>
  16. /* forward declaration */
  17. struct Map_info;
  18. struct node
  19. {
  20. int next;
  21. double z;
  22. };
  23. struct BinIndex
  24. {
  25. int num_nodes;
  26. int max_nodes;
  27. struct node *nodes;
  28. };
  29. struct PointBinning
  30. {
  31. int method;
  32. int bin_n;
  33. int bin_min;
  34. int bin_max;
  35. int bin_sum;
  36. int bin_sumsq;
  37. int bin_index;
  38. int bin_coordinates;
  39. void *n_array;
  40. void *min_array;
  41. void *max_array;
  42. void *sum_array;
  43. void *sumsq_array;
  44. void *index_array;
  45. void *x_array;
  46. void *y_array;
  47. int pth;
  48. double trim;
  49. };
  50. int check_rows_cols_fit_to_size_t(int rows, int cols);
  51. void point_binning_memory_test(struct PointBinning *point_binning, int rows,
  52. int cols, RASTER_MAP_TYPE rtype);
  53. void point_binning_set(struct PointBinning *point_binning, char *method,
  54. char *percentile, char *trim, int coordinates);
  55. void point_binning_allocate(struct PointBinning *point_binning, int rows,
  56. int cols, RASTER_MAP_TYPE rtype);
  57. void point_binning_free(struct PointBinning *point_binning,
  58. struct BinIndex *bin_index_nodes);
  59. int update_bin_index(struct BinIndex *bin_index, void *index_array,
  60. int cols, int row, int col,
  61. RASTER_MAP_TYPE map_type, double value);
  62. void write_variance(void *raster_row, void *n_array, void *sum_array,
  63. void *sumsq_array, int row, int cols,
  64. RASTER_MAP_TYPE rtype, int method);
  65. void write_median(struct BinIndex *bin_index, void *raster_row,
  66. void *index_array, int row, int cols,
  67. RASTER_MAP_TYPE rtype);
  68. void write_percentile(struct BinIndex *bin_index, void *raster_row,
  69. void *index_array, int row, int cols,
  70. RASTER_MAP_TYPE rtype, int pth);
  71. void write_skewness(struct BinIndex *bin_index, void *raster_row,
  72. void *index_array, int row, int cols,
  73. RASTER_MAP_TYPE rtype);
  74. void write_trimmean(struct BinIndex *bin_index, void *raster_row,
  75. void *index_array, int row, int cols,
  76. RASTER_MAP_TYPE rtype, double trim);
  77. /* forward declarations */
  78. struct Map_info;
  79. struct line_pnts;
  80. struct line_cats;
  81. struct VectorWriter
  82. {
  83. struct Map_info *info;
  84. struct line_pnts *points;
  85. struct line_cats *cats;
  86. #ifdef HAVE_LONG_LONG_INT
  87. unsigned long long count;
  88. #else
  89. unsigned long count;
  90. #endif
  91. };
  92. void write_values(struct PointBinning *point_binning,
  93. struct BinIndex *bin_index_nodes, void *raster_row, int row,
  94. int cols, RASTER_MAP_TYPE rtype,
  95. struct VectorWriter *vector_writer);
  96. void update_value(struct PointBinning *point_binning,
  97. struct BinIndex *bin_index_nodes, int cols, int arr_row,
  98. int arr_col, RASTER_MAP_TYPE rtype, double x, double y,
  99. double z);
  100. #endif /* __POINT_BINNING_H__ */