pg_local_proto.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef __PG_LOCAL_PROTO_H__
  2. #define __PG_LOCAL_PROTO_H__
  3. #include <grass/vector.h>
  4. #ifdef HAVE_POSTGRES
  5. #include <libpq-fe.h>
  6. #define CURSOR_PAGE 500
  7. /*! Topological access */
  8. #define TOPO_SCHEMA "topology"
  9. #define TOPO_ID "topology_id"
  10. #define TOPO_TABLE "grass"
  11. #define TOPO_BBOX "bbox"
  12. #define SWAP32(x) \
  13. ((unsigned int)( \
  14. (((unsigned int)(x) & (unsigned int)0x000000ffUL) << 24) | \
  15. (((unsigned int)(x) & (unsigned int)0x0000ff00UL) << 8) | \
  16. (((unsigned int)(x) & (unsigned int)0x00ff0000UL) >> 8) | \
  17. (((unsigned int)(x) & (unsigned int)0xff000000UL) >> 24) ))
  18. #define SWAPDOUBLE(x) \
  19. { \
  20. unsigned char temp, *data = (unsigned char *) (x); \
  21. \
  22. temp = data[0]; \
  23. data[0] = data[7]; \
  24. data[7] = temp; \
  25. temp = data[1]; \
  26. data[1] = data[6]; \
  27. data[6] = temp; \
  28. temp = data[2]; \
  29. data[2] = data[5]; \
  30. data[5] = temp; \
  31. temp = data[3]; \
  32. data[3] = data[4]; \
  33. data[4] = temp; \
  34. }
  35. #define LSBWORD32(x) (x)
  36. #define MSBWORD32(x) SWAP32(x)
  37. /* used for building pseudo-topology (requires some extra information
  38. * about lines in cache) */
  39. struct feat_parts
  40. {
  41. int a_parts; /* number of allocated items */
  42. int n_parts; /* number of parts which forms given feature */
  43. SF_FeatureType *ftype; /* simple feature type */
  44. int *nlines; /* number of lines used in cache */
  45. int *idx; /* index in cache where to start */
  46. };
  47. /* area_pg.c */
  48. int Vect__get_area_points_pg(const struct Map_info *, const plus_t *, int, struct line_pnts *);
  49. /* read_pg.c */
  50. SF_FeatureType Vect__cache_feature_pg(const char *, int, int,
  51. struct Format_info_cache *,
  52. struct feat_parts *);
  53. int Vect__open_cursor_next_line_pg(struct Format_info_pg *, int);
  54. int Vect__open_cursor_line_pg(struct Format_info_pg *, int, int);
  55. int Vect__close_cursor_pg(struct Format_info_pg *);
  56. int Vect__select_line_pg(struct Format_info_pg *, int, int);
  57. int Vect__execute_pg(PGconn *, const char *);
  58. int Vect__execute_get_value_pg(PGconn *, const char *);
  59. /* write_pg.c */
  60. off_t V2__write_node_pg(struct Map_info *, const struct line_pnts *);
  61. off_t V2__write_area_pg(struct Map_info *, const struct line_pnts **, int,
  62. const struct line_cats *);
  63. int Vect__insert_face_pg(struct Map_info *, int);
  64. /* open_pg.c */
  65. int Vect__load_plus_pg(struct Map_info *, int);
  66. int Vect__open_new_pg(struct Map_info *, int);
  67. #endif /* HAVE_POSTGRES */
  68. #endif /* __PG_LOCAL_PROTO_H__ */