39#include "pg_local_proto.h"
43static int get_sftype(
const struct line_pnts *,
int,
int);
44static void print_point(
const struct line_pnts *,
int,
int,
int,
FILE *);
65 return get_sftype(Points, type, with_z);
114 return check_sftype(Points, type,
sftype, with_z);
194 print_point(Points, 0, with_z, precision,
file);
204 for (i = 0; i < Points->
n_points; i++) {
205 print_point(Points, i, with_z, precision,
file);
215 for (i = 0; i < Points->
n_points; i++) {
216 print_point(Points, i, with_z, precision,
file);
276 if (npoints > 2 && Points->
x[0] == Points->
x[npoints - 1] &&
277 Points->
y[0] == Points->
y[npoints - 1]) {
280 if (Points->
z[0] == Points->
z[npoints - 1])
315 !
Map->fInfo.pg.toposchema_name) {
329 snprintf(stmt,
sizeof(stmt),
"SELECT count(*) FROM \"%s\".\"%s\"",
333 G_warning(
_(
"Unable to get number of simple features"));
337 G_fatal_error(
_(
"GRASS is not compiled with PostgreSQL support"));
343 G_warning(
_(
"Unable to report simple features for vector map <%s>"),
352int check_sftype(
const struct line_pnts *points,
int type,
377int get_sftype(
const struct line_pnts *points,
int type,
int with_z)
379 if (check_sftype(points, type,
SF_POINT, with_z))
388 if (check_sftype(points, type,
SF_POLYGON, with_z))
394void print_point(
const struct line_pnts *Points,
int index,
int with_z,
397 fprintf(
file,
"%.*f %.*f", precision, Points->
x[index], precision,
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
char * G_store(const char *)
Copy string to allocated memory.
int Vect_get_num_line_points(const struct line_pnts *)
Get number of line points.
const char * Vect_get_full_name(struct Map_info *)
Get fully qualified name of vector map.
SF_FeatureType
Simple feature types.
#define GV_FORMAT_POSTGIS
PostGIS format.
#define GV_POINT
Feature types used in memory on run time (may change)
#define GV_FORMAT_OGR_DIRECT
OGR format (direct access)
#define GV_FORMAT_OGR
OGR format.
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
int Vect__execute_get_value_pg(PGconn *conn, const char *stmt)
Execute SQL statement and get value.
int Vect_sfa_line_astext(const struct line_pnts *Points, int type, int with_z, int precision, FILE *file)
Export geometry to Well-Known Text.
char * Vect_sfa_line_geometry_type(const struct line_pnts *Points, int type)
Get geometry type (string)
SF_FeatureType Vect_sfa_get_line_type(const struct line_pnts *Points, int type, int with_z)
Get SF type of given vector feature.
int Vect_sfa_check_line_type(const struct line_pnts *Points, int type, SF_FeatureType sftype, int with_z)
Check SF type.
int Vect_sfa_get_num_features(struct Map_info *Map)
Get number of simple features.
int Vect_sfa_is_line_closed(const struct line_pnts *Points, int type, int with_z)
Check if feature is closed.
int Vect_sfa_line_dimension(int type)
Get geometry dimension.
int Vect_sfa_is_line_simple(const struct line_pnts *Points, int type, int with_z)
Check if feature is simple.
int Vect_sfa_get_type(SF_FeatureType sftype)
Get relevant GV type.
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
int n_points
Number of points.
double * z
Array of Z coordinates.