49 G_debug(3,
"Vect_read_line_geos(): line = %d", line);
53 _(
"vector map is not opened"));
57 _(
"Vect_read_line_geos(): feature id %d is not reasonable "
58 "(max features in vector map <%s>: %d)"),
63 _(
"only native format supported"));
68 _(
"Attempt to read dead line"), line);
70 return Vect__read_line_geos(Map, Line->
offset,
type);
89 G_debug(3,
"Vect_read_area_geos(): area = %d", area);
93 G_fatal_error(
_(
"Vect_read_area_geos(): unable to read area id %d"),
99 for (i = 0; i < nholes; i++) {
108 G_fatal_error(
_(
"Vect_read_area_geos(): unable to read isle id %d "
113 poly = GEOSGeom_createPolygon(boundary, holes, nholes);
144 G_debug(3,
"Vect_line_to_geos(): type = %d",
type);
161 pseq = GEOSCoordSeq_create(points->
n_points, with_z ? 3 : 2);
163 for (i = 0; i < points->
n_points; i++) {
164 GEOSCoordSeq_setX(pseq, i, points->
x[i]);
165 GEOSCoordSeq_setY(pseq, i, points->
y[i]);
167 GEOSCoordSeq_setZ(pseq, i, points->
z[i]);
171 geom = GEOSGeom_createPoint(pseq);
173 geom = GEOSGeom_createLineString(pseq);
175 geom = GEOSGeom_createLineString(pseq);
176 if (GEOSisRing(geom)) {
178 geom = GEOSGeom_createLinearRing(pseq);
208 pseq = V1_read_line_geos(Map,
offset, &ftype);
213 G_debug(3,
" geos_type = point");
214 geom = GEOSGeom_createPoint(pseq);
217 G_debug(3,
" geos_type = linestring");
218 geom = GEOSGeom_createLineString(pseq);
221 geom = GEOSGeom_createLineString(pseq);
222 if (GEOSisRing(geom)) {
224 geom = GEOSGeom_createLinearRing(pseq);
225 G_debug(3,
" geos_type = linearring");
228 G_debug(3,
" geos_type = linestring");
257 G_debug(3,
"V2_read_line_geos(): line = %d", line);
263 _(
"Attempt to read dead line"), line);
265 return V1_read_line_geos(Map, Line->
offset, &ftype);
308 return GEOSCoordSeq_create(0, (Map->
head.
with_z) ? 3 : 2);
321 return GEOSCoordSeq_create(0, (Map->
head.
with_z) ? 3 : 2);
334 G_debug(3,
" n_cats = %d", n_cats);
353 G_debug(3,
" n_points = %d dim = %d", n_points,
356 x = (
double *)
G_malloc(n_points *
sizeof(
double));
357 y = (
double *)
G_malloc(n_points *
sizeof(
double));
359 z = (
double *)
G_malloc(n_points *
sizeof(
double));
377 pseq = GEOSCoordSeq_create(n_points, (Map->
head.
with_z) ? 3 : 2);
379 for (i = 0; i < n_points; i++) {
380 GEOSCoordSeq_setX(pseq, i,
x[i]);
381 GEOSCoordSeq_setY(pseq, i, y[i]);
383 GEOSCoordSeq_setZ(pseq, i, z[i]);
416 G_debug(3,
"Vect_get_area_points_geos(): area = %d", area);
419 Area = Plus->
Area[area];
422 G_warning(
_(
"Attempt to read points of nonexistent area id %d"), area);
426 return read_polygon_points(Map, Area->
n_lines, Area->
lines);
447 G_debug(3,
"Vect_get_isle_points_geos(): isle = %d", isle);
450 Isle = Plus->
Isle[isle];
452 return read_polygon_points(Map, Isle->
n_lines, Isle->
lines);
460 unsigned int n_points, n_points_shell;
472 for (i = 0; i <
n_lines; i++) {
475 G_debug(3,
" append line(%d) = %d", i, line);
482 pseq[i] = V2_read_line_geos(Map, aline);
487 GEOSCoordSeq_getSize(pseq[i], &n_points);
488 G_debug(3,
" line n_points = %d", n_points);
489 n_points_shell += n_points;
493 pseq_shell = GEOSCoordSeq_create(n_points_shell, Map->
head.
with_z ? 3 : 2);
495 for (i = 0; i <
n_lines; i++) {
496 GEOSCoordSeq_getSize(pseq[i], &n_points);
498 for (j = 0; j < (int)n_points; j++, k++) {
499 GEOSCoordSeq_getX(pseq[i], j, &
x);
500 GEOSCoordSeq_setX(pseq_shell, k,
x);
502 GEOSCoordSeq_getY(pseq[i], j, &y);
503 GEOSCoordSeq_setY(pseq_shell, k, y);
506 GEOSCoordSeq_getY(pseq[i], j, &z);
507 GEOSCoordSeq_setZ(pseq_shell, k, z);
512 for (j = (
int)n_points - 1; j > -1; j--, k++) {
513 GEOSCoordSeq_getX(pseq[i], j, &
x);
514 GEOSCoordSeq_setX(pseq_shell, k,
x);
516 GEOSCoordSeq_getY(pseq[i], j, &y);
517 GEOSCoordSeq_setY(pseq_shell, k, y);
520 GEOSCoordSeq_getY(pseq[i], j, &z);
521 GEOSCoordSeq_setZ(pseq_shell, k, z);
525 GEOSCoordSeq_destroy(pseq[i]);
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
int G_debug(int, const char *,...) __attribute__((format(printf
const char * Vect_get_full_name(struct Map_info *)
Get fully qualified name of vector map.
int Vect_get_area_isle(struct Map_info *, int, int)
Returns isle id for area.
int Vect_get_area_num_isles(struct Map_info *, int)
Returns number of isles for given area.
#define GV_POINT
Feature types used in memory on run time (may change)
#define VECT_OPEN(Map)
Check if vector map is open.
#define GV_FORWARD
Line direction indicator forward/backward.
#define GV_FORMAT_NATIVE
Geometry data formats supported by lib Don't change GV_FORMAT_* values, this order is hardcoded in li...
int dig__fread_port_D(double *, size_t, struct gvfile *)
Read doubles from the Portable Vector Format.
off_t dig_ftell(struct gvfile *file)
Get struct gvfile position.
int dig_set_cur_port(struct Port_info *)
Set current Port_info structure.
int dig__fread_port_C(char *, size_t, struct gvfile *)
Read chars from the Portable Vector Format.
int dig__fread_port_I(int *, size_t, struct gvfile *)
Read integers from the Portable Vector Format.
int dig_fseek(struct gvfile *file, off_t offset, int whence)
Set struct gvfile position.
int dig_type_from_store(int)
Convert type from store type.
GEOSCoordSequence * Vect_get_isle_points_geos(struct Map_info *Map, int isle)
Returns the polygon (isle) array of points (inner ring)
GEOSGeometry * Vect_read_line_geos(struct Map_info *Map, int line, int *type)
Read vector feature and stores it as GEOSGeometry instance.
GEOSGeometry * Vect_read_area_geos(struct Map_info *Map, int area)
Read vector area and stores it as GEOSGeometry instance (polygon)
GEOSCoordSequence * Vect_get_area_points_geos(struct Map_info *Map, int area)
Returns the polygon array of points, i.e. outer ring (shell)
GEOSGeometry * Vect_line_to_geos(const struct line_pnts *points, int type, int with_z)
Create GEOSGeometry of given type from feature points.
struct gvfile dig_fp
GV file pointer (native format only)
struct dig_head head
Header info.
int format
Map format (native, ogr, postgis)
struct Plus_head plus
Plus info (topology, version, ...)
plus_t n_lines
Number of boundary lines.
plus_t * lines
List of boundary lines.
plus_t * lines
List of boundary lines.
plus_t n_lines
Number of boundary lines.
off_t offset
Offset in coor file for line.
Basic topology-related info.
struct P_line ** Line
Array of vector geometries.
plus_t n_lines
Current number of lines.
struct P_area ** Area
Array of areas.
struct P_isle ** Isle
Array of isles.
int minor
Current version (minor)
struct Version_info coor_version
Version info for coor file.
off_t last_offset
Offset of last read line.
int with_z
2D/3D vector data
struct Port_info port
Portability information.
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.
struct GEOSCoordSeq_t GEOSCoordSequence
struct GEOSGeom_t GEOSGeometry