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 *);
67 return get_sftype(Points, type, with_z);
117 return check_sftype(Points, type, sftype, with_z);
189 int precision, FILE *
file)
197 fprintf(
file,
"POINT(");
198 print_point(Points, 0, with_z, precision,
file);
199 fprintf(
file,
")\n");
205 fprintf(
file,
"LINESTRING(");
207 fprintf(
file,
"LINEARRING(");
208 for (i = 0; i < Points->
n_points; i++) {
209 print_point(Points, i, with_z, precision,
file);
210 if (i < Points->n_points - 1)
213 fprintf(
file,
")\n");
219 for (i = 0; i < Points->
n_points; i++) {
220 print_point(Points, i, with_z, precision,
file);
221 if (i < Points->n_points - 1)
228 G_warning(
_(
"Unknown Simple Features type (%d)"), sftype);
278 if (npoints > 2 && Points->
x[0] == Points->
x[npoints - 1] &&
279 Points->
y[0] == Points->
y[npoints - 1]) {
282 if (Points->
z[0] == Points->
z[npoints - 1])
312 if (!ogr_info->
layer)
315 return OGR_L_GetFeatureCount(ogr_info->
layer,
TRUE);
336 sprintf(stmt,
"SELECT count(*) FROM \"%s\".\"%s\"",
340 G_warning(
_(
"Unable to get number of simple features"));
344 G_fatal_error(
_(
"GRASS is not compiled with PostgreSQL support"));
349 G_warning(
_(
"Unable to report simple features for vector map <%s>"),
357 int check_sftype(
const struct line_pnts *points,
int type,
382 int get_sftype(
const struct line_pnts *points,
int type,
int with_z)
384 if (check_sftype(points, type,
SF_POINT, with_z))
393 if (check_sftype(points, type,
SF_POLYGON, with_z))
399 void print_point(
const struct line_pnts *Points,
int index,
int with_z,
400 int precision, FILE *
file)
402 fprintf(
file,
"%.*f %.*f", precision, Points->
x[index], precision,
405 fprintf(
file,
" %.*f", precision, Points->
z[index]);
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.
const char * Vect_get_full_name(struct Map_info *)
Get fully qualified name of vector map.
int Vect_get_num_line_points(const struct line_pnts *)
Get number of line points.
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.
SF_FeatureType Vect_sfa_get_line_type(const struct line_pnts *Points, int type, int with_z)
Get SF type of given vector feature.
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.
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 UNUSED, int type UNUSED, int with_z UNUSED)
Check if feature is simple.
int Vect_sfa_get_type(SF_FeatureType sftype)
Get relevant GV type.
int format
Map format (native, ogr, postgis)
struct Format_info fInfo
Format info for non-native formats.
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.