23 static int cache_feature(
struct Map_info *, OGRGeometryH,
int);
24 static int read_line(
const struct Map_info *, OGRGeometryH,
long,
26 static int get_line_type(
const struct Map_info *,
long);
54 return read_next_line_ogr(Map, line_p, line_c,
FALSE);
84 G_debug(3,
"V2_read_next_line_ogr()");
110 if (line_p !=
NULL) {
123 for (i = 0; i < list.
n_values; i++) {
124 if (list.
id[i] == line) {
133 if (line_c !=
NULL) {
142 ret = read_next_line_ogr(Map, line_p, line_c,
TRUE);
190 G_debug(3,
"V1_read_line_ogr(): offset = %lu offset_num = %lu",
205 if (line_p !=
NULL) {
208 G_debug(4,
"Read feature (fid = %ld) to cache", fid);
213 OGR_L_GetFeature(ogr_info->
layer, fid);
215 G_warning(
_(
"Unable to get feature geometry, fid %ld"),
224 G_warning(
_(
"Unable to get feature geometry, fid %ld"),
229 type = read_line(Map, hGeom, offset + 1, line_p);
232 type = get_line_type(Map, fid);
236 if (line_c !=
NULL) {
260 int cache_feature(
struct Map_info *Map, OGRGeometryH hGeom,
int ftype)
262 int line, i, np, ng, tp;
266 OGRwkbGeometryType type;
269 G_debug(4,
"cache_feature() ftype = %d", ftype);
286 for (i = ogr_info->
cache.
lines_num; i < ogr_info->cache.lines_alloc; i++)
291 type = wkbFlatten(OGR_G_GetGeometryType(hGeom));
297 OGR_G_GetX(hGeom, 0), OGR_G_GetY(hGeom, 0),
298 OGR_G_GetZ(hGeom, 0));
306 np = OGR_G_GetPointCount(hGeom);
307 for (i = 0; i < np; i++) {
309 OGR_G_GetX(hGeom, i), OGR_G_GetY(hGeom, i),
310 OGR_G_GetZ(hGeom, i));
324 case wkbMultiLineString:
326 case wkbMultiPolygon:
327 case wkbGeometryCollection:
328 ng = OGR_G_GetGeometryCount(hGeom);
329 G_debug(4,
"%d geoms -> next level", ng);
330 if (type == wkbPolygon) {
336 for (i = 0; i < ng; i++) {
337 hGeom2 = OGR_G_GetGeometryRef(hGeom, i);
338 cache_feature(Map, hGeom2, tp);
344 G_warning(
_(
"OGR feature type %d not supported"), type);
351 struct line_cats *line_c,
int ignore_constraint)
355 OGRFeatureH hFeature;
360 G_debug(3,
"V1_read_next_line_ogr()");
375 hFeature = OGR_L_GetNextFeature(ogr_info->
layer);
376 if (hFeature ==
NULL) {
380 hGeom = OGR_F_GetGeometryRef(hFeature);
382 G_warning(
_(
"Feature without geometry. Skipped."));
383 OGR_F_Destroy(hFeature);
388 ogr_info->
cache.
fid = (int)OGR_F_GetFID(hFeature);
389 if (ogr_info->
cache.
fid == OGRNullFID) {
395 cache_feature(Map, hGeom, -1);
397 OGR_F_Destroy(hFeature);
432 if (line_c !=
NULL && ogr_info->
cache.
fid != OGRNullFID)
436 G_debug(4,
"next line read, type = %d", itype);
455 int read_line(
const struct Map_info *Map, OGRGeometryH hGeom,
long offset,
471 eType = wkbFlatten(OGR_G_GetGeometryType(hGeom));
472 G_debug(4,
"OGR geometry type: %d", eType);
479 OGR_G_GetZ(hGeom, 0));
487 nPoints = OGR_G_GetPointCount(hGeom);
488 for (i = 0; i < nPoints; i++) {
490 OGR_G_GetY(hGeom, i), OGR_G_GetZ(hGeom, i));
498 case wkbMultiLineString:
499 case wkbMultiPolygon:
500 case wkbGeometryCollection:
503 line = read_line(Map, hGeom2,
offset + 1, Points);
504 if (eType == wkbPolygon || eType == wkbMultiPolygon)
506 if (eType == wkbMultiPoint)
508 if (eType == wkbMultiLineString)
514 G_warning(
_(
"OGR feature type '%s' not supported"),
515 OGRGeometryTypeToName(eType));
533 int get_line_type(
const struct Map_info *Map,
long fid)
542 G_debug(4,
"get_line_type() fid = %ld", fid);
546 hFeat = OGR_L_GetFeature(ogr_info->
layer, fid);
550 hGeom = OGR_F_GetGeometryRef(hFeat);
554 eType = wkbFlatten(OGR_G_GetGeometryType(hGeom));
556 OGR_F_Destroy(hFeat);
558 G_debug(4,
"OGR Geometry of type: %d", eType);
567 case wkbMultiLineString:
572 case wkbMultiPolygon:
573 case wkbGeometryCollection:
578 G_warning(
_(
"OGR feature type %d not supported"), eType);
int Vect_get_area_box(const struct Map_info *, int, struct bound_box *)
Get bounding box of area.
int Vect_append_points(struct line_pnts *, const struct line_pnts *, int)
Appends points to the end of a line.
#define GV_FORWARD
Line direction indicator forward/backward.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
plus_t area
Area number, negative for duplicate centroid.
off_t offset
Offset in coor file for line.
struct P_line ** Line
Array of vector geometries.
int region_flag
Non-zero value to enable region constraint.
int V2_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c)
Read next feature from OGR layer on topological level.
struct Format_info fInfo
Format info for non-native formats.
void Vect_line_box(const struct line_pnts *, struct bound_box *)
Get bounding box of line.
int V1_read_line_ogr(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, off_t offset)
Read feature from OGR layer at given offset (level 1 without topology)
int type
Feature type constraint.
int n_values
Number of items in the list.
#define GV_POINT
Feature types used in memory on run time (may change)
struct bound_box * box
Array of bounding boxes.
plus_t n_lines
Current number of lines.
int Vect_select_lines_by_box(struct Map_info *, const struct bound_box *, int, struct boxlist *)
Select lines with bounding boxes by box.
Feature geometry info - coordinates.
plus_t next_line
Feature id for sequential access.
struct Map_info::@11 constraint
Constraints for sequential feature access.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
void * topo
Topology info.
int Vect_get_constraint_box(const struct Map_info *, struct bound_box *)
Get constraint box.
int Vect_append_point(struct line_pnts *, double, double, double)
Appends one point to the end of a line.
struct Plus_head plus
Plus info (topology, version, ...)
int Vect_reset_cats(struct line_cats *)
Reset category structure to make sure cats structure is clean to be re-used.
int dig_init_boxlist(struct boxlist *, int)
int V1_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c)
Read next feature from OGR layer. Skip empty features (level 1 without topology). ...
int type_flag
Non-zero value to enable feature type constraint.
List of bounding boxes with id.
void G_warning(const char *,...) __attribute__((format(printf
int Vect_box_overlap(const struct bound_box *, const struct bound_box *)
Tests for overlap of two boxes.
int G_debug(int, const char *,...) __attribute__((format(printf
void Vect_reset_line(struct line_pnts *)
Reset line.
int Vect_cat_set(struct line_cats *, int, int)
Add new field/cat to category structure if doesn't exist yet.