site.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef GRASS_SITEDEFS_H
  2. #define GRASS_SITEDEFS_H
  3. /* Allocate 'num' SITE_XYZ structs. Returns NULL on failure */
  4. SITE_XYZ *G_alloc_site_xyz(size_t);
  5. /* Free the array of SITE_XYZ struct */
  6. void G_free_site_xyz(SITE_XYZ *);
  7. /* G_readsites_xyz: Reads a sites file converting to a site struct of xyz
  8. * values and the cat value. The Z value can come from one of the
  9. * n-dimensions, a double attribute, or a string attribute converted to a
  10. * double with strtod(). The 'size' must not be greater than the number
  11. * of elements in the SITE_XYZ array, or bad things will happen. The number
  12. * of records read is returned or EOF on end of file. NOTE: EOF won't be
  13. * returned unless no records are read and the EOF bit is set. It's safe
  14. * to assume that if the number of records read is less than the size of
  15. * the array, that there aren't any more records.
  16. */
  17. int G_readsites_xyz(FILE *, /* The FILE stream to the sites file */
  18. int, /* Attribute type: SITE_COL_DIM, etc... */
  19. int, /* The field index (1 based) for the attribute */
  20. int, /* Size of the array */
  21. struct Cell_head *, /* Respect region if not NULL */
  22. SITE_XYZ * xyz /* The site array of size 'size' */
  23. );
  24. int G_readsites(FILE *, int, int, int, struct Cell_head *, Z **);
  25. /* The same for old and new, format independent */
  26. Site *G_site_new_struct(RASTER_MAP_TYPE cattype, int ndim, int ns, int nd);
  27. void G_site_free_struct(Site * s);
  28. int G_site_in_region(const Site * s, const struct Cell_head *region);
  29. int G_site_d_cmp(const void *a, const void *b);
  30. int G_site_c_cmp(const void *a, const void *b);
  31. int G_site_s_cmp(const void *a, const void *b);
  32. char *G_site_format(const Site * s, const char *fs, int id);
  33. /* struct site_att * G_sites_get_atts (struct Map_info * ptr, int* cat); */
  34. int G_sites_get_fields(struct Map_info *ptr, char ***cnames, int **ctypes,
  35. int **ndx);
  36. void G_sites_free_fields(int ncols, char **cnames, int *ctypes, int *ndx);
  37. /* Old version used by v.in.sites */
  38. FILE *G_oldsites_open_old(const char *name, const char *mapset);
  39. int G_oldsite_describe(FILE * p, int *dims, int *cat, int *strs, int *dbls);
  40. int G_oldsite_get(FILE * p, Site * s);
  41. int G__oldsite_get(FILE *, Site *, int);
  42. /* New version based on vectors used in old, not updated sites modules */
  43. int G_site_get(struct Map_info *p, Site * s);
  44. int G_site_put(struct Map_info *p, const Site * s);
  45. int G_site_describe(struct Map_info *p, int *dims, int *cat, int *strs,
  46. int *dbls);
  47. int G_site_get_head(struct Map_info *p, Site_head * head);
  48. int G_site_put_head(struct Map_info *p, Site_head * head);
  49. struct Map_info *G_sites_open_old(const char *name, const char *mapset);
  50. struct Map_info *G_sites_open_new(const char *name);
  51. void G_sites_close(struct Map_info *);
  52. const char *G_find_sites(char *name, const char *mapset);
  53. const char *G_find_sites2(const char *name, const char *mapset);
  54. int G__site_put(struct Map_info *, Site *, int);
  55. struct Map_info *G_fopen_sites_old(const char *, const char *);
  56. struct Map_info *G_fopen_sites_new(const char *);
  57. int G_get_site(struct Map_info *, double *, double *, char **);
  58. int G_put_site(struct Map_info *, double, double, const char *);
  59. #endif