49 G_debug(3,
"Vect_read_line_geos(): line = %d", line);
52 G_fatal_error(
"Vect_read_line_geos(): %s",
_(
"vector map is not opened"));
55 G_fatal_error(
_(
"Vect_read_line_geos(): feature id %d is not reasonable " 56 "(max features in vector map <%s>: %d)"),
60 G_fatal_error(
"Vect_read_line_geos(): %s",
_(
"only native format supported"));
65 _(
"Attempt to read dead line"), line);
67 return Vect__read_line_geos(Map, Line->
offset, type);
86 G_debug(3,
"Vect_read_area_geos(): area = %d", area);
90 G_fatal_error(
_(
"Vect_read_area_geos(): unable to read area id %d"),
96 for (i = 0; i < nholes; i++) {
104 G_fatal_error(
_(
"Vect_read_area_geos(): unable to read isle id %d of area id %d"),
108 poly = GEOSGeom_createPolygon(boundary, holes, nholes);
133 int type,
int with_z)
139 G_debug(3,
"Vect_line_to_geos(): type = %d", type);
156 pseq = GEOSCoordSeq_create(points->
n_points, with_z ? 3 : 2);
158 for (i = 0; i < points->
n_points; i++) {
159 GEOSCoordSeq_setX(pseq, i, points->
x[i]);
160 GEOSCoordSeq_setY(pseq, i, points->
y[i]);
162 GEOSCoordSeq_setZ(pseq, i, points->
z[i]);
166 geom = GEOSGeom_createPoint(pseq);
168 geom = GEOSGeom_createLineString(pseq);
170 geom = GEOSGeom_createLineString(pseq);
171 if (GEOSisRing(geom)) {
173 geom = GEOSGeom_createLinearRing(pseq);
203 pseq = V1_read_line_geos(Map,
offset, &ftype);
208 G_debug(3,
" geos_type = point");
209 geom = GEOSGeom_createPoint(pseq);
212 G_debug(3,
" geos_type = linestring");
213 geom = GEOSGeom_createLineString(pseq);
216 geom = GEOSGeom_createLineString(pseq);
217 if (GEOSisRing(geom)) {
219 geom = GEOSGeom_createLinearRing(pseq);
220 G_debug(3,
" geos_type = linearring");
223 G_debug(3,
" geos_type = linestring");
252 G_debug(3,
"V2_read_line_geos(): line = %d", line);
258 _(
"Attempt to read dead line"), line);
260 return V1_read_line_geos(Map, Line->
offset, &ftype);
303 return GEOSCoordSeq_create(0, (Map->
head.
with_z) ? 3 : 2);
315 return GEOSCoordSeq_create(0, (Map->
head.
with_z) ? 3 : 2);
328 G_debug(3,
" n_cats = %d", n_cats);
349 pseq = GEOSCoordSeq_create(n_points, (Map->
head.
with_z) ? 3 : 2);
351 x = (
double *)
G_malloc(n_points *
sizeof(
double));
352 y = (
double *)
G_malloc(n_points *
sizeof(
double));
354 z = (
double *)
G_malloc(n_points *
sizeof(
double));
370 for (i = 0; i < n_points; i++) {
371 GEOSCoordSeq_setX(pseq, i, x[i]);
372 GEOSCoordSeq_setY(pseq, i, y[i]);
374 GEOSCoordSeq_setZ(pseq, i, z[i]);
406 G_debug(3,
"Vect_get_area_points_geos(): area = %d", area);
409 Area = Plus->
Area[area];
412 G_warning(
_(
"Attempt to read points of nonexistent area id %d"), area);
416 return read_polygon_points(Map, Area->
n_lines, Area->
lines);
437 G_debug(3,
"Vect_get_isle_points_geos(): isle = %d", isle);
440 Isle = Plus->
Isle[isle];
442 return read_polygon_points(Map, Isle->
n_lines, Isle->
lines);
449 unsigned int n_points, n_points_shell;
460 for (i = 0; i <
n_lines; i++) {
463 G_debug(3,
" append line(%d) = %d", i, line);
470 pseq[i] = V2_read_line_geos(Map, aline);
475 GEOSCoordSeq_getSize(pseq[i], &n_points);
476 G_debug(3,
" line n_points = %d", n_points);
477 n_points_shell += n_points;
481 pseq_shell = GEOSCoordSeq_create(n_points_shell, Map->
head.
with_z ? 3 : 2);
483 for (i = 0; i <
n_lines; i++) {
484 GEOSCoordSeq_getSize(pseq[i], &n_points);
486 for (j = 0; j < (int) n_points; j++, k++) {
487 GEOSCoordSeq_getX(pseq[i], j, &x);
488 GEOSCoordSeq_setX(pseq_shell, k, x);
490 GEOSCoordSeq_getY(pseq[i], j, &y);
491 GEOSCoordSeq_setY(pseq_shell, k, y);
494 GEOSCoordSeq_getY(pseq[i], j, &z);
495 GEOSCoordSeq_setZ(pseq_shell, k, z);
500 for (j = (
int) n_points - 1; j > -1; j--, k++) {
501 GEOSCoordSeq_getX(pseq[i], j, &x);
502 GEOSCoordSeq_setX(pseq_shell, k, x);
504 GEOSCoordSeq_getY(pseq[i], j, &y);
505 GEOSCoordSeq_setY(pseq_shell, k, y);
508 GEOSCoordSeq_getY(pseq[i], j, &z);
509 GEOSCoordSeq_setZ(pseq_shell, k, z);
513 GEOSCoordSeq_destroy(pseq[i]);
struct Version_info coor_version
Version info for coor file.
GEOSCoordSequence * Vect_get_area_points_geos(struct Map_info *Map, int area)
Returns the polygon array of points, i.e. outer ring (shell)
#define GV_FORWARD
Line direction indicator forward/backward.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int Vect_get_area_isle(const struct Map_info *, int, int)
Returns isle id for area.
off_t offset
Offset in coor file for line.
#define GV_FORMAT_NATIVE
Geometry data formats supported by lib Don't change GV_FORMAT_* values, this order is hardcoded in li...
struct P_line ** Line
Array of vector geometries.
int dig__fread_port_I(int *, size_t, struct gvfile *)
Read integers from the Portable Vector Format.
GEOSCoordSequence * Vect_get_isle_points_geos(struct Map_info *Map, int isle)
Returns the polygon (isle) array of points (inner ring)
int dig__fread_port_C(char *, size_t, struct gvfile *)
Read chars from the Portable Vector Format.
struct P_area ** Area
Array of areas.
int n_points
Number of points.
void G_free(void *)
Free allocated memory.
int Vect_get_area_num_isles(const struct Map_info *, int)
Returns number of isles for given area.
struct P_isle ** Isle
Array of isles.
plus_t n_lines
Number of boundary lines.
#define GV_POINT
Feature types used in memory on run time (may change)
GEOSGeometry * Vect_read_line_geos(struct Map_info *Map, int line, int *type)
Read vector feature and stores it as GEOSGeometry instance.
off_t dig_ftell(struct gvfile *file)
Get struct gvfile position.
plus_t n_lines
Current number of lines.
double * x
Array of X coordinates.
Feature geometry info - coordinates.
int with_z
2D/3D vector data
#define VECT_OPEN(Map)
Check if vector map is open.
plus_t * lines
List of boundary lines.
GEOSGeometry * Vect_line_to_geos(const struct line_pnts *points, int type, int with_z)
Create GEOSGeometry of given type from feature points.
Basic topology-related info.
struct Port_info port
Portability information.
int dig_type_from_store(int)
Convert type from store type.
struct GEOSGeom_t GEOSGeometry
plus_t * lines
List of boundary lines.
struct Plus_head plus
Plus info (topology, version, ...)
struct dig_head head
Header info.
struct GEOSCoordSeq_t GEOSCoordSequence
double * y
Array of Y coordinates.
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
double * z
Array of Z coordinates.
struct gvfile dig_fp
GV file pointer (native format only)
off_t last_offset
Offset of last read line.
int format
Map format (native, ogr, postgis)
int minor
Current version (minor)
int dig_set_cur_port(struct Port_info *)
Set current Port_info structure.
GEOSGeometry * Vect_read_area_geos(struct Map_info *Map, int area)
Read vector area and stores it as GEOSGeometry instance (polygon)
plus_t n_lines
Number of boundary lines.
int G_debug(int, const char *,...) __attribute__((format(printf
int dig_fseek(struct gvfile *file, off_t offset, int whence)
Set struct gvfile position.
int dig__fread_port_D(double *, size_t, struct gvfile *)
Read doubles from the Portable Vector Format.