forked from lduchesne/cmatopo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpg.h
More file actions
64 lines (49 loc) · 1.22 KB
/
pg.h
File metadata and controls
64 lines (49 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef __CMA_PG_H
#define __CMA_PG_H
#include <string>
#include <libpq-fe.h>
#include <ogrsf_frmts.h>
#include <types.h>
namespace cma {
class PG
{
public:
PG(const std::string& connect_str);
~PG();
bool connected() const;
PGresult* query(const std::string& sql, bool single_row_mode=false);
PGresult* next_result();
bool success(PGresult* res) const;
int get_line_count();
/**
* Below are some geometry helpers.
*/
GEOSGeometry* get_line(int id);
bool get_lines(
const GEOSGeometry* envelope,
linesV& lines,
bool within=true,
int limit=-1);
bool get_common_lines(
const OGREnvelope& env1,
const OGREnvelope& env2,
linesV& lines,
int limit=-1);
bool get_line_ids(
const GEOSGeometry* envelope,
std::set<int>& line_ids,
bool within=true,
int limit=-1);
bool get_lines(
const std::set<int> lineIds,
linesV& lines);
std::string build_pg_geom(const GEOSGeometry* geom) const;
private:
std::string _build_query(
const GEOSGeometry* geom,
bool within,
int limit);
PGconn* _conn = NULL;
};
} // namespace cma
#endif // __CMA_PG_H