23 static int cache_feature(
struct Map_info *, OGRGeometryH,
int);
25 static int get_line_type(
struct Map_info *,
long);
53 return read_next_line_ogr(Map, line_p, line_c,
FALSE);
83 G_debug(3,
"V2_read_next_line_ogr()");
109 if (line_p !=
NULL) {
122 for (i = 0; i <
list.n_values; i++) {
123 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);
214 G_warning(
_(
"Unable to get feature geometry, fid %ld"), fid);
222 G_warning(
_(
"Unable to get feature geometry, fid %ld"), fid);
226 type = read_line(Map, hGeom,
offset + 1, line_p);
229 type = get_line_type(Map, fid);
233 if (line_c !=
NULL) {
259 int cache_feature(
struct Map_info *Map, OGRGeometryH hGeom,
int ftype)
261 int line, i, np, ng, tp;
265 OGRwkbGeometryType type;
268 G_debug(4,
"cache_feature() ftype = %d", ftype);
284 for (i = ogr_info->
cache.
lines_num; i < ogr_info->cache.lines_alloc;
290 type = wkbFlatten(OGR_G_GetGeometryType(hGeom));
296 OGR_G_GetY(hGeom, 0), OGR_G_GetZ(hGeom, 0));
304 np = OGR_G_GetPointCount(hGeom);
305 for (i = 0; i < np; i++) {
307 OGR_G_GetY(hGeom, i), OGR_G_GetZ(hGeom, i));
321 case wkbMultiLineString:
323 case wkbMultiPolygon:
324 case wkbGeometryCollection:
325 ng = OGR_G_GetGeometryCount(hGeom);
326 G_debug(4,
"%d geoms -> next level", ng);
327 if (type == wkbPolygon) {
333 for (i = 0; i < ng; i++) {
334 hGeom2 = OGR_G_GetGeometryRef(hGeom, i);
335 cache_feature(Map, hGeom2, tp);
341 G_warning(
_(
"OGR feature type %d not supported"), type);
348 struct line_cats *line_c,
int ignore_constraint)
352 OGRFeatureH hFeature;
357 G_debug(3,
"V1_read_next_line_ogr()");
372 hFeature = OGR_L_GetNextFeature(ogr_info->
layer);
373 if (hFeature ==
NULL) {
377 hGeom = OGR_F_GetGeometryRef(hFeature);
379 G_warning(
_(
"Feature without geometry. Skipped."));
380 OGR_F_Destroy(hFeature);
385 ogr_info->
cache.
fid = (int)OGR_F_GetFID(hFeature);
386 if (ogr_info->
cache.
fid == OGRNullFID) {
392 cache_feature(Map, hGeom, -1);
394 OGR_F_Destroy(hFeature);
430 if (line_c !=
NULL && ogr_info->
cache.
fid != OGRNullFID)
434 G_debug(4,
"next line read, type = %d", itype);
453 int read_line(
struct Map_info *Map, OGRGeometryH hGeom,
long offset,
469 eType = wkbFlatten(OGR_G_GetGeometryType(hGeom));
470 G_debug(4,
"OGR geometry type: %d", eType);
477 OGR_G_GetY(hGeom, 0), OGR_G_GetZ(hGeom, 0));
485 nPoints = OGR_G_GetPointCount(hGeom);
486 for (i = 0; i < nPoints; i++) {
488 OGR_G_GetY(hGeom, i), OGR_G_GetZ(hGeom, i));
496 case wkbMultiLineString:
497 case wkbMultiPolygon:
498 case wkbGeometryCollection:
501 line = read_line(Map, hGeom2,
offset + 1, Points);
502 if (eType == wkbPolygon || eType == wkbMultiPolygon)
504 if (eType == wkbMultiPoint)
506 if (eType == wkbMultiLineString)
512 G_warning(
_(
"OGR feature type '%s' not supported"),
513 OGRGeometryTypeToName(eType));
531 int get_line_type(
struct Map_info *Map,
long fid)
540 G_debug(4,
"get_line_type() fid = %ld", fid);
544 hFeat = OGR_L_GetFeature(ogr_info->
layer, fid);
548 hGeom = OGR_F_GetGeometryRef(hFeat);
552 eType = wkbFlatten(OGR_G_GetGeometryType(hGeom));
554 OGR_F_Destroy(hFeat);
556 G_debug(4,
"OGR Geometry of type: %d", eType);
565 case wkbMultiLineString:
570 case wkbMultiPolygon:
571 case wkbGeometryCollection:
576 G_warning(
_(
"OGR feature type %d not supported"), eType);
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
int Vect_reset_cats(struct line_cats *)
Reset category structure to make sure cats structure is clean to be re-used.
void Vect_line_box(const struct line_pnts *, struct bound_box *)
Get bounding box of line.
int Vect_cat_set(struct line_cats *, int, int)
Add new field/cat to category structure if doesn't exist yet.
int Vect_get_constraint_box(struct Map_info *, struct bound_box *)
Get constraint box.
int Vect_box_overlap(const struct bound_box *, const struct bound_box *)
Tests for overlap of two boxes.
int Vect_get_area_box(struct Map_info *, int, struct bound_box *)
Get bounding box of area.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int Vect_select_lines_by_box(struct Map_info *, const struct bound_box *, int, struct boxlist *)
Select lines with bounding boxes by box.
void Vect_reset_line(struct line_pnts *)
Reset line.
int Vect_append_point(struct line_pnts *, double, double, double)
Appends one point to the end of a line.
int Vect_append_points(struct line_pnts *, const struct line_pnts *, int)
Appends points to the end of a line.
#define GV_POINT
Feature types used in memory on run time (may change)
#define GV_FORWARD
Line direction indicator forward/backward.
int dig_init_boxlist(struct boxlist *, int)
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 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 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.
plus_t next_line
Feature id for sequential access.
int type
Feature type constraint.
int type_flag
Non-zero value to enable feature type constraint.
struct Map_info::@11 constraint
Constraints for sequential feature access.
int region_flag
Non-zero value to enable region constraint.
struct Format_info fInfo
Format info for non-native formats.
struct Plus_head plus
Plus info (topology, version, ...)
off_t offset
Offset in coor file for line.
void * topo
Topology info.
plus_t area
Area number, negative for duplicate centroid.
struct P_line ** Line
Array of vector geometries.
plus_t n_lines
Current number of lines.
List of bounding boxes with id.
Feature geometry info - coordinates.