37 #include "pg_local_proto.h" 45 static int get_sftype(
const struct line_pnts *,
int,
int);
46 static void print_point(
const struct line_pnts *,
int,
int,
int, FILE *);
66 return get_sftype(Points, type, with_z);
116 return check_sftype(Points, type, sftype, with_z);
195 fprintf(file,
"POINT(");
196 print_point(Points, 0, with_z, precision, file);
197 fprintf(file,
")\n");
202 fprintf(file,
"LINESTRING(");
204 fprintf(file,
"LINEARRING(");
205 for (i = 0; i < Points->
n_points; i++) {
206 print_point(Points, i, with_z, precision, file);
207 if (i < Points->n_points - 1)
210 fprintf(file,
")\n");
216 for (i = 0; i < Points->
n_points; i++) {
217 print_point(Points, i, with_z, precision, file);
218 if (i < Points->n_points - 1)
225 G_warning(
_(
"Unknown Simple Features type (%d)"), sftype);
271 Points->
x[0] == Points->
x[npoints-1] &&
272 Points->
y[0] == Points->
y[npoints-1]) {
275 if (Points->
z[0] == Points->
z[npoints-1])
305 if (!ogr_info->
layer)
308 return OGR_L_GetFeatureCount(ogr_info->
layer,
TRUE);
328 sprintf(stmt,
"SELECT count(*) FROM \"%s\".\"%s\"", pg_info->
schema_name,
332 G_warning(
_(
"Unable to get number of simple features"));
336 G_fatal_error(
_(
"GRASS is not compiled with PostgreSQL support"));
341 G_warning(
_(
"Unable to report simple features for vector map <%s>"),
349 int check_sftype(
const struct line_pnts *points,
int type,
374 int get_sftype(
const struct line_pnts *points,
int type,
int with_z)
376 if (check_sftype(points, type,
SF_POINT, with_z))
385 if (check_sftype(points, type,
SF_POLYGON, with_z))
391 void print_point(
const struct line_pnts *Points,
int index,
int with_z,
int precision, FILE *
file)
393 fprintf(file,
"%.*f %.*f", precision, Points->
x[index], precision, Points->
y[index]);
395 fprintf(file,
" %.*f", precision, Points->
z[index]);
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int Vect_sfa_is_line_closed(const struct line_pnts *Points, int type, int with_z)
Check if feature is closed.
int Vect_sfa_get_type(SF_FeatureType sftype)
Get relevant GV type.
int n_points
Number of points.
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.
#define GV_FORMAT_OGR
OGR format.
struct Format_info fInfo
Format info for non-native formats.
int Vect_sfa_get_num_features(const struct Map_info *Map)
Get number of simple features.
#define GV_POINT
Feature types used in memory on run time (may change)
double * x
Array of X coordinates.
int Vect__execute_get_value_pg(PGconn *conn, const char *stmt)
Execute SQL statement and get value.
Feature geometry info - coordinates.
int Vect_get_num_line_points(const struct line_pnts *)
Get number of line points.
#define GV_FORMAT_OGR_DIRECT
OGR format (direct access)
int Vect_sfa_line_dimension(int type)
Get geometry dimension.
#define GV_FORMAT_POSTGIS
PostGIS format.
double * y
Array of Y coordinates.
int Vect_sfa_is_line_simple(const struct line_pnts *Points, int type, int with_z)
Check if feature is simple.
const char * Vect_get_full_name(const struct Map_info *)
Get fully qualified name of vector map.
void G_warning(const char *,...) __attribute__((format(printf
SF_FeatureType Vect_sfa_get_line_type(const struct line_pnts *Points, int type, int with_z)
Get SF type of given vector feature.
double * z
Array of Z coordinates.
int format
Map format (native, ogr, postgis)
char * G_store(const char *)
Copy string to allocated memory.
char * Vect_sfa_line_geometry_type(const struct line_pnts *Points, int type)
Get geometry type (string)
int Vect_sfa_check_line_type(const struct line_pnts *Points, int type, SF_FeatureType sftype, int with_z)
Check SF type.
SF_FeatureType
Simple feature types.