[GRASS-SVN] r51028 - in grass/trunk: include/defs lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Mar 11 06:37:29 EDT 2012
Author: martinl
Date: 2012-03-11 03:37:29 -0700 (Sun, 11 Mar 2012)
New Revision: 51028
Added:
grass/trunk/lib/vector/Vlib/read_sfa.c
Modified:
grass/trunk/include/defs/vector.h
grass/trunk/lib/vector/Vlib/read.c
grass/trunk/lib/vector/Vlib/read_ogr.c
grass/trunk/lib/vector/Vlib/read_pg.c
grass/trunk/lib/vector/Vlib/write.c
grass/trunk/lib/vector/Vlib/write_ogr.c
grass/trunk/lib/vector/Vlib/write_pg.c
grass/trunk/lib/vector/Vlib/write_sfa.c
Log:
vlib(pg): introduce V2_read_line_sfa()
implement V1_delete_line_pg() and V2_delete_line_sfa()
Modified: grass/trunk/include/defs/vector.h
===================================================================
--- grass/trunk/include/defs/vector.h 2012-03-10 20:07:05 UTC (rev 51027)
+++ grass/trunk/include/defs/vector.h 2012-03-11 10:37:29 UTC (rev 51028)
@@ -493,6 +493,8 @@
struct line_cats *, off_t);
int V1_read_line_ogr(struct Map_info *, struct line_pnts *,
struct line_cats *, off_t);
+int V1_read_line_pg(struct Map_info *, struct line_pnts *,
+ struct line_cats *, off_t);
int V1_read_next_line_nat(struct Map_info *, struct line_pnts *,
struct line_cats *);
int V1_read_next_line_ogr(struct Map_info *, struct line_pnts *,
@@ -501,10 +503,8 @@
struct line_cats *);
int V2_read_line_nat(struct Map_info *, struct line_pnts *,
struct line_cats *, int);
-int V2_read_line_ogr(struct Map_info *, struct line_pnts *,
+int V2_read_line_sfa(struct Map_info *, struct line_pnts *,
struct line_cats *, int);
-int V2_read_line_pg(struct Map_info *, struct line_pnts *,
- struct line_cats *, int);
int V2_read_next_line_nat(struct Map_info *, struct line_pnts *,
struct line_cats *);
int V2_read_next_line_ogr(struct Map_info *, struct line_pnts *,
@@ -514,7 +514,8 @@
int V1_delete_line_nat(struct Map_info *, off_t);
int V2_delete_line_nat(struct Map_info *, int);
int V1_delete_line_ogr(struct Map_info *, off_t);
-int V2_delete_line_ogr(struct Map_info *, int);
+int V1_delete_line_pg(struct Map_info *, off_t);
+int V2_delete_line_sfa(struct Map_info *, int);
int V1_restore_line_nat(struct Map_info *, off_t);
int V2_restore_line_nat(struct Map_info *, int, off_t);
off_t V1_write_line_nat(struct Map_info *, int, const struct line_pnts *,
Modified: grass/trunk/lib/vector/Vlib/read.c
===================================================================
--- grass/trunk/lib/vector/Vlib/read.c 2012-03-10 20:07:05 UTC (rev 51027)
+++ grass/trunk/lib/vector/Vlib/read.c 2012-03-11 10:37:29 UTC (rev 51028)
@@ -60,14 +60,14 @@
static int (*Read_line_array[]) () = {
V2_read_line_nat
#ifdef HAVE_OGR
- , V2_read_line_ogr
- , V2_read_line_ogr
+ , V2_read_line_sfa
+ , V2_read_line_sfa
#else
, format
, format
#endif
#ifdef HAVE_POSTGRES
- , V2_read_line_pg
+ , V2_read_line_sfa
#else
, format
#endif
Modified: grass/trunk/lib/vector/Vlib/read_ogr.c
===================================================================
--- grass/trunk/lib/vector/Vlib/read_ogr.c 2012-03-10 20:07:05 UTC (rev 51027)
+++ grass/trunk/lib/vector/Vlib/read_ogr.c 2012-03-11 10:37:29 UTC (rev 51028)
@@ -244,83 +244,7 @@
#endif
}
-/*!
- \brief Reads feature from OGR layer on topological level.
-
- This function implements random access on level 2.
-
- \param Map pointer to Map_info structure
- \param[out] line_p container used to store line points within
- (pointer to line_pnts struct)
- \param[out] line_c container used to store line categories within
- (pointer to line_cats struct)
- \param line feature id (starts at 1)
-
- \return feature type
- \return -2 no more features
- \return -1 on failure
-*/
-int V2_read_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
- struct line_cats *line_c, int line)
-{
#ifdef HAVE_OGR
- struct P_line *Line;
-
- G_debug(4, "V2_read_line_ogr() line = %d", line);
-
- Line = Map->plus.Line[line];
- if (Line == NULL) {
- G_warning(_("Attempt to read dead feature %d"), line);
- return -1;
- }
-
- if (Line->type == GV_CENTROID) {
- /* read centroid for topo */
- if (line_p != NULL) {
- int i, found;
- struct bound_box box;
- struct boxlist list;
- struct P_topo_c *topo = (struct P_topo_c *)Line->topo;
-
- G_debug(4, "Centroid: area = %d", topo->area);
- Vect_reset_line(line_p);
-
- if (topo->area > 0 && topo->area <= Map->plus.n_areas) {
- /* get area bbox */
- Vect_get_area_box(Map, topo->area, &box);
- /* search in spatial index for centroid with area bbox */
- dig_init_boxlist(&list, TRUE);
- Vect_select_lines_by_box(Map, &box, Line->type, &list);
-
- found = 0;
- for (i = 0; i < list.n_values; i++) {
- if (list.id[i] == line) {
- found = i;
- break;
- }
- }
-
- Vect_append_point(line_p, list.box[found].E, list.box[found].N, 0.0);
- }
- }
-
- if (line_c != NULL) {
- /* cat = fid and offset = fid for centroid */
- Vect_reset_cats(line_c);
- Vect_cat_set(line_c, 1, (int) Line->offset);
- }
-
- return GV_CENTROID;
- }
-
- return V1_read_line_ogr(Map, line_p, line_c, Line->offset);
-#else
- G_fatal_error(_("GRASS is not compiled with OGR support"));
- return -1;
-#endif
-}
-
-#ifdef HAVE_OGR
/*!
\brief Recursively read feature and add all elements to points_cache and types_cache.
Modified: grass/trunk/lib/vector/Vlib/read_pg.c
===================================================================
--- grass/trunk/lib/vector/Vlib/read_pg.c 2012-03-10 20:07:05 UTC (rev 51027)
+++ grass/trunk/lib/vector/Vlib/read_pg.c 2012-03-11 10:37:29 UTC (rev 51028)
@@ -236,30 +236,32 @@
fid = pg_info->offset.array[offset];
G_debug(4, " fid = %ld", fid);
- /* coordinates */
- if (line_p != NULL) {
- /* read feature to cache if necessary */
- if (pg_info->cache.fid != fid) {
- G_debug(4, "read feature (fid = %ld) to cache", fid);
- sf_type = (int) get_feature(pg_info, fid);
-
- if ((int) sf_type < 0)
- return (int) sf_type;
- }
+ /* read feature to cache if necessary */
+ if (pg_info->cache.fid != fid) {
+ G_debug(4, "read feature (fid = %ld) to cache", fid);
+ sf_type = (int) get_feature(pg_info, fid);
- ipart = pg_info->offset.array[offset + 1];
- G_debug(4, "read feature part: %d", ipart);
+ if ((int) sf_type < 0)
+ return (int) sf_type;
+ }
+
+ /* get data from cache */
+ ipart = pg_info->offset.array[offset + 1];
+ type = pg_info->cache.lines_types[ipart];
+ G_debug(4, "read feature part: %d -> type = %d",
+ ipart, type);
- /* get data from cache */
- type = pg_info->cache.lines_types[ipart];
+ if (line_p != NULL) {
+ /* coordinates */
line_i = pg_info->cache.lines[ipart];
for (i = 0; i < line_i->n_points; i++) {
Vect_append_point(line_p,
line_i->x[i], line_i->y[i], line_i->z[i]);
}
}
-
+
if (line_c != NULL) {
+ /* category */
Vect_cat_set(line_c, 1, (int) fid);
}
@@ -270,92 +272,7 @@
#endif
}
-/*!
- \brief Reads feature from PostGIS layer on topological level.
-
- This function implements random access on level 2.
-
- \param Map pointer to Map_info structure
- \param[out] line_p container used to store line points within
- (pointer to line_pnts struct)
- \param[out] line_c container used to store line categories within
- (pointer to line_cats struct)
- \param line feature id (starts at 1)
-
- \return feature type
- \return -2 no more features
- \return -1 on failure
-*/
-int V2_read_line_pg(struct Map_info *Map, struct line_pnts *line_p,
- struct line_cats *line_c, int line)
-{
#ifdef HAVE_POSTGRES
- struct P_line *Line;
-
- G_debug(3, "V2_read_line_pg() line = %d", line);
-
- Line = Map->plus.Line[line];
- if (Line == NULL) {
- G_warning(_("Attempt to read dead feature %d"), line);
- return -1;
- }
-
- if (Line->type == GV_CENTROID) {
- /* read centroid from topo */
- if (line_p != NULL) {
- int i, found;
- struct bound_box box;
- struct boxlist list;
- struct P_topo_c *topo = (struct P_topo_c *)Line->topo;
-
- G_debug(4, "Centroid: area = %d", topo->area);
- Vect_reset_line(line_p);
-
- if (topo->area > 0 && topo->area <= Map->plus.n_areas) {
- /* get area bbox */
- Vect_get_area_box(Map, topo->area, &box);
- /* search in spatial index for centroid with area bbox */
- dig_init_boxlist(&list, TRUE);
- Vect_select_lines_by_box(Map, &box, Line->type, &list);
-
- found = -1;
- for (i = 0; i < list.n_values; i++) {
- if (list.id[i] == line) {
- found = i;
- break;
- }
- }
-
- if (found > -1) {
- Vect_append_point(line_p, list.box[found].E, list.box[found].N, 0.0);
- }
- else {
- G_warning(_("Unable to construct centroid for area %d. Skipped."),
- topo->area);
- }
- }
- else {
- G_warning(_("Centroid %d: invalid area %d"), line, topo->area);
- }
- }
-
- if (line_c != NULL) {
- /* cat = FID and offset = FID for centroid */
- Vect_reset_cats(line_c);
- Vect_cat_set(line_c, 1, (int) Line->offset);
- }
-
- return GV_CENTROID;
- }
-
- return V1_read_line_pg(Map, line_p, line_c, Line->offset);
-#else
- G_fatal_error(_("GRASS is not compiled with PostgreSQL support"));
- return -1;
-#endif
-}
-
-#ifdef HAVE_POSTGRES
/*!
\brief Read next feature from PostGIS layer.
Added: grass/trunk/lib/vector/Vlib/read_sfa.c
===================================================================
--- grass/trunk/lib/vector/Vlib/read_sfa.c (rev 0)
+++ grass/trunk/lib/vector/Vlib/read_sfa.c 2012-03-11 10:37:29 UTC (rev 51028)
@@ -0,0 +1,111 @@
+/*!
+ \file lib/vector/Vlib/read_sfa.c
+
+ \brief Vector library - reading features - simple feature access
+
+ Higher level functions for reading/writing/manipulating vectors.
+
+ See read_ogr.c (OGR interface) and read_pg.c (PostGIS interface)
+ for imlementation issues.
+
+ (C) 2011-2012 by the GRASS Development Team
+
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
+
+ \author Martin Landa <landa.martin gmail.com>
+*/
+
+#include <grass/vector.h>
+#include <grass/glocale.h>
+
+/*!
+ \brief Reads feature from OGR/PostGIS layer on topological level.
+
+ This function implements random access on level 2.
+
+ \param Map pointer to Map_info structure
+ \param[out] line_p container used to store line points within
+ (pointer to line_pnts struct)
+ \param[out] line_c container used to store line categories within
+ (pointer to line_cats struct)
+ \param line feature id (starts at 1)
+
+ \return feature type
+ \return -2 no more features
+ \return -1 on failure
+*/
+int V2_read_line_sfa(struct Map_info *Map, struct line_pnts *line_p,
+ struct line_cats *line_c, int line)
+{
+#if defined HAVE_OGR || defined HAVE_POSTGRES
+ struct P_line *Line;
+
+ G_debug(4, "V2_read_line_sfa() line = %d", line);
+
+ Line = Map->plus.Line[line];
+ if (Line == NULL) {
+ G_warning(_("Attempt to read dead feature %d"), line);
+ return -1;
+ }
+
+ if (Line->type == GV_CENTROID) {
+ /* read centroid for topo */
+ if (line_p != NULL) {
+ int i, found;
+ struct bound_box box;
+ struct boxlist list;
+ struct P_topo_c *topo = (struct P_topo_c *)Line->topo;
+
+ G_debug(4, "Centroid: area = %d", topo->area);
+ Vect_reset_line(line_p);
+
+ if (topo->area > 0 && topo->area <= Map->plus.n_areas) {
+ /* get area bbox */
+ Vect_get_area_box(Map, topo->area, &box);
+ /* search in spatial index for centroid with area bbox */
+ dig_init_boxlist(&list, TRUE);
+ Vect_select_lines_by_box(Map, &box, Line->type, &list);
+
+ found = -1;
+ for (i = 0; i < list.n_values; i++) {
+ if (list.id[i] == line) {
+ found = i;
+ break;
+ }
+ }
+
+ if (found > -1) {
+ Vect_append_point(line_p, list.box[found].E, list.box[found].N, 0.0);
+ }
+ else {
+ G_warning(_("Unable to construct centroid for area %d. Skipped."),
+ topo->area);
+ }
+ }
+ else {
+ G_warning(_("Centroid %d: invalid area %d"), line, topo->area);
+ }
+ }
+
+ if (line_c != NULL) {
+ /* cat = fid and offset = fid for centroid */
+ Vect_reset_cats(line_c);
+ Vect_cat_set(line_c, 1, (int) Line->offset);
+ }
+
+ return GV_CENTROID;
+ }
+
+ if (!line_p && !line_c)
+ return Line->type;
+
+ if (Map->format == GV_FORMAT_POSTGIS)
+ return V1_read_line_pg(Map, line_p, line_c, Line->offset);
+
+ return V1_read_line_ogr(Map, line_p, line_c, Line->offset);
+#else
+ G_fatal_error(_("GRASS is not compiled with OGR/PostgreSQL support"));
+ return -1;
+#endif
+}
Property changes on: grass/trunk/lib/vector/Vlib/read_sfa.c
___________________________________________________________________
Added: svn:mime-type
+ text/x-csrc
Added: svn:eol-style
+ native
Modified: grass/trunk/lib/vector/Vlib/write.c
===================================================================
--- grass/trunk/lib/vector/Vlib/write.c 2012-03-10 20:07:05 UTC (rev 51027)
+++ grass/trunk/lib/vector/Vlib/write.c 2012-03-11 10:37:29 UTC (rev 51028)
@@ -116,9 +116,9 @@
delete_dummy, V1_delete_line_nat, V2_delete_line_nat}
#ifdef HAVE_OGR
, {
- delete_dummy, V1_delete_line_ogr, V2_delete_line_ogr}
+ delete_dummy, V1_delete_line_ogr, V2_delete_line_sfa}
, {
- delete_dummy, V1_delete_line_ogr, V2_delete_line_ogr}
+ delete_dummy, V1_delete_line_ogr, V2_delete_line_sfa}
#else
, {
delete_dummy, format, format}
@@ -127,7 +127,7 @@
#endif
#ifdef HAVE_POSTGRES
, {
- delete_dummy, delete_dummy, delete_dummy}
+ delete_dummy, V1_delete_line_pg, V2_delete_line_sfa}
#else
, {
delete_dummy, format, format}
@@ -275,7 +275,7 @@
}
if (!(Map->plus.update_cidx)) {
- Map->plus.cidx_up_to_date = 0;
+ Map->plus.cidx_up_to_date = FALSE;
}
ret = (*Vect_delete_line_array[Map->format][Map->level]) (Map, line);
Modified: grass/trunk/lib/vector/Vlib/write_ogr.c
===================================================================
--- grass/trunk/lib/vector/Vlib/write_ogr.c 2012-03-10 20:07:05 UTC (rev 51027)
+++ grass/trunk/lib/vector/Vlib/write_ogr.c 2012-03-11 10:37:29 UTC (rev 51028)
@@ -258,12 +258,12 @@
line, type, offset);
#ifdef HAVE_OGR
- if (type != V2_read_line_ogr(Map, NULL, NULL, line)) {
+ if (type != V2_read_line_sfa(Map, NULL, NULL, line)) {
G_warning(_("Unable to rewrite feature (incompatible feature types)"));
return -1;
}
- V2_delete_line_ogr(Map, line);
+ V2_delete_line_sfa(Map, line);
return V2_write_line_sfa(Map, type, points, cats);
#else
@@ -295,11 +295,14 @@
return -1;
}
- if (offset >= ogr_info->offset.array_num)
+ if (offset >= ogr_info->offset.array_num) {
+ G_warning(_("Invalid offset (%d)"), offset);
return -1;
+ }
if (OGR_L_DeleteFeature(ogr_info->layer,
ogr_info->offset.array[offset]) != OGRERR_NONE)
+ G_warning(_("Unable to delete feature"));
return -1;
return 0;
@@ -309,88 +312,7 @@
#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, int line)
-{
#ifdef HAVE_OGR
- 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", 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;
-#else
- G_fatal_error(_("GRASS is not compiled with OGR support"));
- return -1;
-#endif
-}
-
-#ifdef HAVE_OGR
int write_attributes(dbDriver *driver, int cat, const struct field_info *Fi,
OGRLayerH Ogr_layer, OGRFeatureH Ogr_feature)
{
Modified: grass/trunk/lib/vector/Vlib/write_pg.c
===================================================================
--- grass/trunk/lib/vector/Vlib/write_pg.c 2012-03-10 20:07:05 UTC (rev 51027)
+++ grass/trunk/lib/vector/Vlib/write_pg.c 2012-03-11 10:37:29 UTC (rev 51028)
@@ -74,6 +74,11 @@
pg_info = &(Map->fInfo.pg);
offset_info = &(pg_info->offset);
+ if (!pg_info->conn || !pg_info->table_name) {
+ G_warning(_("No connection defined"));
+ return -1;
+ }
+
/* create PostGIS layer if doesn't exist ? */
cat = -1; /* no attributes to be written */
@@ -179,7 +184,63 @@
#endif
}
+/*!
+ \brief Deletes feature at the given offset (level 1)
+
+ \param Map pointer Map_info structure
+ \param offset feature offset
+
+ \return 0 on success
+ \return -1 on error
+*/
+int V1_delete_line_pg(struct Map_info *Map, off_t offset)
+{
#ifdef HAVE_POSTGRES
+ long fid;
+ char stmt[DB_SQL_MAX];
+
+ struct Format_info_pg *pg_info;
+
+ pg_info = &(Map->fInfo.pg);
+
+ if (!pg_info->conn || !pg_info->table_name) {
+ G_warning(_("No connection defined"));
+ return -1;
+ }
+
+ if (offset >= pg_info->offset.array_num) {
+ G_warning(_("Invalid offset (%d)"), offset);
+ return -1;
+ }
+
+ fid = pg_info->offset.array[offset];
+
+ G_debug(3, "V1_delete_line_pg(), offset = %lu -> fid = %ld",
+ (unsigned long) offset, fid);
+
+ if (execute(pg_info->conn, "BEGIN") == -1)
+ return -1;
+
+ sprintf(stmt, "DELETE FROM %s WHERE %s = %ld",
+ pg_info->table_name, pg_info->fid_column, fid);
+ G_debug(2, "SQL: %s", stmt);
+
+ if (execute(pg_info->conn, stmt) == -1) {
+ G_warning(_("Unable to delete feature"));
+ return -1;
+ }
+
+ if (execute(pg_info->conn, "COMMIT") == -1)
+ return -1;
+
+ return 0;
+#else
+ G_fatal_error(_("GRASS is not compiled with PostgreSQL support"));
+ return -1;
+#endif
+}
+
+#ifdef HAVE_POSTGRES
/*!
\brief Binary data to HEX
Modified: grass/trunk/lib/vector/Vlib/write_sfa.c
===================================================================
--- grass/trunk/lib/vector/Vlib/write_sfa.c 2012-03-10 20:07:05 UTC (rev 51027)
+++ grass/trunk/lib/vector/Vlib/write_sfa.c 2012-03-11 10:37:29 UTC (rev 51028)
@@ -79,7 +79,7 @@
if (type == GV_BOUNDARY) {
int ret, cline;
- long FID;
+ long fid;
double x, y;
struct bound_box box;
@@ -91,14 +91,14 @@
CPoints = Vect_new_line_struct();
Vect_append_point(CPoints, x, y, 0.0);
- FID = offset_info->array[offset];
+ fid = offset_info->array[offset];
dig_line_box(CPoints, &box);
cline = dig_add_line(plus, GV_CENTROID,
- CPoints, &box, FID);
+ CPoints, &box, fid);
G_debug(4, "\tCentroid: x = %f, y = %f, cat = %lu, line = %d",
- x, y, FID, cline);
- dig_cidx_add_cat(plus, 1, (int) FID,
+ x, y, fid, cline);
+ dig_cidx_add_cat(plus, 1, (int) fid,
cline, GV_CENTROID);
Vect_destroy_line_struct(CPoints);
@@ -123,7 +123,94 @@
#endif
}
+/*!
+ \brief Deletes feature (topology level) -- internal use only
+
+ \todo Update fidx
+
+ \param pointer to Map_info structure
+ \param line feature id
+
+ \return 0 on success
+ \return -1 on error
+*/
+int V2_delete_line_sfa(struct Map_info *Map, int line)
+{
#if defined HAVE_OGR || defined HAVE_POSTGRES
+ 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_sfa(), line = %d", 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_sfa(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 */
+ /* TODO */
+
+ /* delete the line from coor */
+ if (Map->format == GV_FORMAT_POSTGIS)
+ ret = V1_delete_line_pg(Map, Line->offset);
+ else
+ 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;
+#else
+ G_fatal_error(_("GRASS is not compiled with OGR/PostgreSQL support"));
+ return -1;
+#endif
+}
+
+#if defined HAVE_OGR || defined HAVE_POSTGRES
/*!
\brief Add feature to topo file (internal use only)
More information about the grass-commit
mailing list