19 #include "pg_local_proto.h" 49 res = build_stmt(&(Map->
plus), pg_info, lines, n_lines);
53 for (i = 0; i < n_lines; i++) {
68 const plus_t *lines,
int n_lines)
72 char *stmt, *stmt_id, buf_id[128];
80 stmt_id = (
char *)
G_malloc(stmt_id_size);
83 for (i = 0; i < n_lines; i++) {
84 if (strlen(stmt_id) + 100 > stmt_id_size) {
86 stmt_id = (
char *)
G_realloc(stmt_id, stmt_id_size);
89 BLine = plus->
Line[line];
92 sprintf(buf_id,
"%d", (
int) BLine->
offset);
93 strcat(stmt_id, buf_id);
100 G_asprintf(&stmt,
"SELECT geom FROM \"%s\".edge_data AS t " 101 "JOIN (SELECT id, row_number() over() AS id_sorter FROM " 102 "(SELECT UNNEST(ARRAY[%s]) AS id) AS y) x ON " 103 "t.edge_id in (%s) AND x.id = t.edge_id " 108 res = PQexec(pg_info->
conn, stmt);
111 if (!res || PQresultStatus(res) != PGRES_TUPLES_OK ||
112 PQntuples(res) != n_lines) {
int Vect_append_points(struct line_pnts *, const struct line_pnts *, int)
Appends points to the end of a line.
#define GV_FORWARD
Line direction indicator forward/backward.
off_t offset
Offset in coor file for line.
struct P_line ** Line
Array of vector geometries.
int n_points
Number of points.
void G_free(void *)
Free allocated memory.
struct Format_info fInfo
Format info for non-native formats.
Feature geometry info - coordinates.
Basic topology-related info.
struct Plus_head plus
Plus info (topology, version, ...)
SF_FeatureType Vect__cache_feature_pg(const char *data, int skip_polygon, int force_type, struct Format_info_cache *cache, struct feat_parts *fparts)
Read geometry from HEX data.
int Vect__get_area_points_pg(const struct Map_info *Map, const plus_t *lines, int n_lines, struct line_pnts *APoints)
Get area boundary points (PostGIS Topology)
int G_asprintf(char **, const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
void Vect_reset_line(struct line_pnts *)
Reset line.