pg_local_proto.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 TOPO_TABLE_NUM 4
  13. #define TOPO_TABLE_NODE "node_grass"
  14. #define TOPO_TABLE_LINE "line_grass"
  15. #define TOPO_TABLE_AREA "area_grass"
  16. #define TOPO_TABLE_ISLE "isle_grass"
  17. #define SWAP32(x) \
  18. ((unsigned int)( \
  19. (((unsigned int)(x) & (unsigned int)0x000000ffUL) << 24) | \
  20. (((unsigned int)(x) & (unsigned int)0x0000ff00UL) << 8) | \
  21. (((unsigned int)(x) & (unsigned int)0x00ff0000UL) >> 8) | \
  22. (((unsigned int)(x) & (unsigned int)0xff000000UL) >> 24) ))
  23. #define SWAPDOUBLE(x) \
  24. { \
  25. unsigned char temp, *data = (unsigned char *) (x); \
  26. \
  27. temp = data[0]; \
  28. data[0] = data[7]; \
  29. data[7] = temp; \
  30. temp = data[1]; \
  31. data[1] = data[6]; \
  32. data[6] = temp; \
  33. temp = data[2]; \
  34. data[2] = data[5]; \
  35. data[5] = temp; \
  36. temp = data[3]; \
  37. data[3] = data[4]; \
  38. data[4] = temp; \
  39. }
  40. #define LSBWORD32(x) (x)
  41. #define MSBWORD32(x) SWAP32(x)
  42. /* used for building pseudo-topology (requires some extra information
  43. * about lines in cache) */
  44. struct feat_parts
  45. {
  46. int a_parts; /* number of allocated items */
  47. int n_parts; /* number of parts which forms given feature */
  48. SF_FeatureType *ftype; /* simple feature type */
  49. int *nlines; /* number of lines used in cache */
  50. int *idx; /* index in cache where to start */
  51. };
  52. /* area_pg.c */
  53. int Vect__get_area_points_pg(const struct Map_info *, const plus_t *, int, struct line_pnts *);
  54. /* build_pg.c */
  55. int Vect__clean_grass_db_topo(struct Format_info_pg *);
  56. /* read_pg.c */
  57. SF_FeatureType Vect__cache_feature_pg(const char *, int, int,
  58. struct Format_info_cache *,
  59. struct feat_parts *);
  60. int Vect__open_cursor_next_line_pg(struct Format_info_pg *, int, int);
  61. int Vect__open_cursor_line_pg(struct Format_info_pg *, int, int);
  62. int Vect__close_cursor_pg(struct Format_info_pg *);
  63. int Vect__select_line_pg(struct Format_info_pg *, int, int);
  64. int Vect__execute_pg(PGconn *, const char *);
  65. int Vect__execute_get_value_pg(PGconn *, const char *);
  66. void Vect__reallocate_cache(struct Format_info_cache *, int, int);
  67. /* write_pg.c */
  68. off_t V2__write_node_pg(struct Map_info *, const struct line_pnts *);
  69. off_t V2__write_area_pg(struct Map_info *, const struct line_pnts **, int,
  70. const struct line_cats *);
  71. int V2__update_area_pg(struct Map_info *, const struct line_pnts **, int,
  72. int);
  73. int Vect__define_topo_relation(const struct Format_info_pg *, int, int);
  74. int Vect__insert_face_pg(struct Map_info *, int);
  75. /* open_pg.c */
  76. int Vect__load_plus_head(struct Map_info *);
  77. int Vect__load_plus_pg(struct Map_info *, int);
  78. int Vect__open_new_pg(struct Map_info *, int);
  79. int Vect__open_topo_pg(struct Map_info *, int, int);
  80. int Vect__load_map_nodes_pg(struct Map_info *, int);
  81. int Vect__load_map_lines_pg(struct Map_info *);
  82. #endif /* HAVE_POSTGRES */
  83. #endif /* __PG_LOCAL_PROTO_H__ */