/*! \brief Rewrites feature at the given offset (level 1) \param Map pointer to Map_info structure \param offset feature offset \param type feature type \param points feature geometry \param cats feature categories \return feature offset (rewriten feature) \return -1 on error */ off_t V1_rewrite_line_ogr(struct Map_info *Map, int line, int type, off_t offset, const struct line_pnts *points, const struct line_cats *cats) { if (type != V1_read_line_ogr(Map, NULL, NULL, offset)) { G_warning(_("Unable to rewrite feature (incompatible feature types)")); return -1; } /* delete old */ V1_delete_line_ogr(Map, offset); return V1_write_line_ogr(Map, type, points, cats); }
/*! \brief Rewrites feature at the given offset on level 1 (OGR interface) This function simply calls V1_delete_line_ogr() and V1_write_line_ogr(). \param Map pointer to Map_info structure \param offset feature offset \param type feature type (see V1_write_line_ogr() for supported types) \param points pointer to line_pnts structure (feature geometry) \param cats pointer to line_cats structure (feature categories) \return feature offset (rewriten feature) \return -1 on error */ off_t V1_rewrite_line_ogr(struct Map_info *Map, int line, int type, off_t offset, const struct line_pnts *points, const struct line_cats *cats) { G_debug(3, "V1_rewrite_line_ogr(): line=%d type=%d offset=%"PRI_OFF_T, line, type, offset); #ifdef HAVE_OGR if (type != V1_read_line_ogr(Map, NULL, NULL, offset)) { G_warning(_("Unable to rewrite feature (incompatible feature types)")); return -1; } /* delete old */ V1_delete_line_ogr(Map, offset); return V1_write_line_ogr(Map, type, points, cats); #else G_fatal_error(_("GRASS is not compiled with OGR support")); return -1; #endif }
/*! \brief Deletes feature (topology level) -- internal use only \param pointer to Map_info structure \param line feature id \return 0 on success \return -1 on error */ int V2_delete_line_ogr(struct Map_info *Map, off_t line) { int ret, i, type, first; struct P_line *Line; struct Plus_head *plus; static struct line_cats *Cats = NULL; static struct line_pnts *Points = NULL; G_debug(3, "V2_delete_line_ogr(), line = %d", (int) line); type = first = 0; Line = NULL; plus = &(Map->plus); if (plus->built >= GV_BUILD_BASE) { Line = Map->plus.Line[line]; if (Line == NULL) G_fatal_error(_("Attempt to delete dead feature")); type = Line->type; } if (!Cats) { Cats = Vect_new_cats_struct(); } if (!Points) { Points = Vect_new_line_struct(); } type = V2_read_line_ogr(Map, Points, Cats, line); /* Update category index */ if (plus->update_cidx) { for (i = 0; i < Cats->n_cats; i++) { dig_cidx_del_cat(plus, Cats->field[i], Cats->cat[i], line, type); } } /* Update fidx */ /* delete the line from coor */ ret = V1_delete_line_ogr(Map, Line->offset); if (ret == -1) { return ret; } /* Update topology */ if (plus->built >= GV_BUILD_AREAS && type == GV_BOUNDARY) { /* TODO */ /* remove centroid together with boundary (is really an OGR polygon) */ } /* Delete reference from area */ if (plus->built >= GV_BUILD_CENTROIDS && type == GV_CENTROID) { /* for OGR mapsets, virtual centroid will be removed when polygon is removed */ } /* delete the line from topo */ dig_del_line(plus, line, Points->x[0], Points->y[0], Points->z[0]); /* Rebuild areas/isles and attach centroids and isles */ if (plus->built >= GV_BUILD_AREAS && type == GV_BOUNDARY) { /* maybe not needed VERIFY */ } return ret; }