Pārlūkot izejas kodu

Vlib: sync write fns, fix for https://trac.osgeo.org/grass/ticket/2583

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@64644 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 10 gadi atpakaļ
vecāks
revīzija
d44f72c194

+ 7 - 7
include/defs/vector.h

@@ -550,11 +550,11 @@ int V2_read_next_line_pg(struct Map_info *, struct line_pnts *,
 int V1_delete_line_nat(struct Map_info *, off_t);
 int V1_delete_line_nat(struct Map_info *, off_t);
 int V1_delete_line_ogr(struct Map_info *, off_t);
 int V1_delete_line_ogr(struct Map_info *, off_t);
 int V1_delete_line_pg(struct Map_info *, off_t);
 int V1_delete_line_pg(struct Map_info *, off_t);
-int V2_delete_line_nat(struct Map_info *, int);
-int V2_delete_line_sfa(struct Map_info *, int);
-int V2_delete_line_pg(struct Map_info *, int);
+int V2_delete_line_nat(struct Map_info *, off_t);
+int V2_delete_line_sfa(struct Map_info *, off_t);
+int V2_delete_line_pg(struct Map_info *, off_t);
 int V1_restore_line_nat(struct Map_info *, off_t);
 int V1_restore_line_nat(struct Map_info *, off_t);
-int V2_restore_line_nat(struct Map_info *, int);
+int V2_restore_line_nat(struct Map_info *, off_t);
 off_t V1_write_line_nat(struct Map_info *, int, const struct line_pnts *,
 off_t V1_write_line_nat(struct Map_info *, int, const struct line_pnts *,
                         const struct line_cats *);
                         const struct line_cats *);
 off_t V1_write_line_ogr(struct Map_info *, int, const struct line_pnts *,
 off_t V1_write_line_ogr(struct Map_info *, int, const struct line_pnts *,
@@ -573,11 +573,11 @@ off_t V1_rewrite_line_ogr(struct Map_info *, off_t, int,
                           const struct line_pnts *, const struct line_cats *);
                           const struct line_pnts *, const struct line_cats *);
 off_t V1_rewrite_line_pg(struct Map_info *, off_t, int,
 off_t V1_rewrite_line_pg(struct Map_info *, off_t, int,
                          const struct line_pnts *, const struct line_cats *);
                          const struct line_pnts *, const struct line_cats *);
-off_t V2_rewrite_line_nat(struct Map_info *, int, int,
+off_t V2_rewrite_line_nat(struct Map_info *, off_t, int,
                           const struct line_pnts *, const struct line_cats *);
                           const struct line_pnts *, const struct line_cats *);
-off_t V2_rewrite_line_sfa(struct Map_info *, int, int,
+off_t V2_rewrite_line_sfa(struct Map_info *, off_t, int,
                           const struct line_pnts *, const struct line_cats *);
                           const struct line_pnts *, const struct line_cats *);
-off_t V2_rewrite_line_pg(struct Map_info *, int, int,
+off_t V2_rewrite_line_pg(struct Map_info *, off_t, int,
                           const struct line_pnts *, const struct line_cats *);
                           const struct line_pnts *, const struct line_cats *);
 
 
     /* Build topology */
     /* Build topology */

+ 11 - 12
lib/vector/Vlib/write_nat.c

@@ -145,16 +145,15 @@ off_t V1_rewrite_line_nat(struct Map_info *Map, off_t offset, int type,
   compatibility with level 1 functions.
   compatibility with level 1 functions.
   
   
   \param Map pointer to Map_info structure
   \param Map pointer to Map_info structure
-  \param type feature type (GV_POINT, GV_LINE, ...)
   \param line feature id to be rewritten
   \param line feature id to be rewritten
-  \param old_offset feature offset
+  \param type feature type (GV_POINT, GV_LINE, ...)
   \param points feature geometry
   \param points feature geometry
   \param cats feature categories
   \param cats feature categories
   
   
   \return new feature id or 0 (build level < GV_BUILD_BASE)
   \return new feature id or 0 (build level < GV_BUILD_BASE)
   \return -1 on error
   \return -1 on error
 */
 */
-off_t V2_rewrite_line_nat(struct Map_info *Map, int line, int type,
+off_t V2_rewrite_line_nat(struct Map_info *Map, off_t line, int type,
 			  const struct line_pnts *points, const struct line_cats *cats)
 			  const struct line_pnts *points, const struct line_cats *cats)
 {
 {
     /* TODO: this is just quick shortcut because we have already V2_delete_nat()
     /* TODO: this is just quick shortcut because we have already V2_delete_nat()
@@ -180,7 +179,7 @@ off_t V2_rewrite_line_nat(struct Map_info *Map, int line, int type,
     }
     }
 
 
     if (line < 1 || line > plus->n_lines) {
     if (line < 1 || line > plus->n_lines) {
-        G_warning(_("Attempt to access feature with invalid id (%d)"), line);
+        G_warning(_("Attempt to access feature with invalid id (%d)"), (int)line);
         return -1;
         return -1;
     }
     }
 
 
@@ -279,7 +278,7 @@ int V1_delete_line_nat(struct Map_info *Map, off_t offset)
   \return 0 on success
   \return 0 on success
   \return -1 on error
   \return -1 on error
 */
 */
-int V2_delete_line_nat(struct Map_info *Map, int line)
+int V2_delete_line_nat(struct Map_info *Map, off_t line)
 {
 {
     int type;
     int type;
     struct P_line *Line;
     struct P_line *Line;
@@ -287,19 +286,19 @@ int V2_delete_line_nat(struct Map_info *Map, int line)
     static struct line_cats *Cats = NULL;
     static struct line_cats *Cats = NULL;
     static struct line_pnts *Points = NULL;
     static struct line_pnts *Points = NULL;
 
 
-    G_debug(3, "V2_delete_line_nat(): line = %d", line);
+    G_debug(3, "V2_delete_line_nat(): line = %d", (int)line);
 
 
     Line = NULL;
     Line = NULL;
     plus = &(Map->plus);
     plus = &(Map->plus);
 
 
     if (line < 1 || line > plus->n_lines) {
     if (line < 1 || line > plus->n_lines) {
-        G_warning(_("Attempt to access feature with invalid id (%d)"), line);
+        G_warning(_("Attempt to access feature with invalid id (%d)"), (int)line);
         return -1;
         return -1;
     }
     }
 
 
     Line = Map->plus.Line[line];
     Line = Map->plus.Line[line];
     if (Line == NULL) {
     if (Line == NULL) {
-        G_warning(_("Attempt to access dead feature %d"), line);
+        G_warning(_("Attempt to access dead feature %d"), (int)line);
         return -1;
         return -1;
     }
     }
 
 
@@ -381,7 +380,7 @@ int V1_restore_line_nat(struct Map_info *Map, off_t offset)
   \return 0 on success
   \return 0 on success
   \return -1 on error
   \return -1 on error
 */
 */
-int V2_restore_line_nat(struct Map_info *Map, int line)
+int V2_restore_line_nat(struct Map_info *Map, off_t line)
 {
 {
     int type;
     int type;
     off_t offset;
     off_t offset;
@@ -392,16 +391,16 @@ int V2_restore_line_nat(struct Map_info *Map, int line)
     
     
     plus = &(Map->plus);
     plus = &(Map->plus);
 
 
-    G_debug(3, "V2_restore_line_nat(), line = %d", line);
+    G_debug(3, "V2_restore_line_nat(), line = %d", (int)line);
 
 
     if (line < 1 || line > plus->n_lines) {
     if (line < 1 || line > plus->n_lines) {
-        G_warning(_("Attempt to access feature with invalid id (%d)"), line);
+        G_warning(_("Attempt to access feature with invalid id (%d)"), (int)line);
         return -1;
         return -1;
     }
     }
     
     
     Line = Map->plus.Line[line];
     Line = Map->plus.Line[line];
     if (Line != NULL) {
     if (Line != NULL) {
-        G_warning(_("Attempt to access alive feature %d"), line);
+        G_warning(_("Attempt to access alive feature %d"), (int)line);
         return -1;
         return -1;
     }
     }
 
 

+ 1 - 1
lib/vector/Vlib/write_ogr.c

@@ -82,7 +82,7 @@ off_t V1_write_line_ogr(struct Map_info *Map, int type,
   \param points pointer to line_pnts structure (feature geometry)
   \param points pointer to line_pnts structure (feature geometry)
   \param cats pointer to line_cats structure (feature categories)
   \param cats pointer to line_cats structure (feature categories)
   
   
-  \return feature offset (rewriten feature)
+  \return feature offset (rewritten feature)
   \return -1 on error
   \return -1 on error
 */
 */
 off_t V1_rewrite_line_ogr(struct Map_info *Map,
 off_t V1_rewrite_line_ogr(struct Map_info *Map,

+ 12 - 12
lib/vector/Vlib/write_pg.c

@@ -172,7 +172,7 @@ off_t V2_write_line_pg(struct Map_info *Map, int type,
    \param points feature geometry
    \param points feature geometry
    \param cats feature categories
    \param cats feature categories
 
 
-   \return feature offset (rewriten feature)
+   \return feature offset (rewritten feature)
    \return -1 on error
    \return -1 on error
  */
  */
 off_t V1_rewrite_line_pg(struct Map_info * Map,
 off_t V1_rewrite_line_pg(struct Map_info * Map,
@@ -207,19 +207,19 @@ off_t V1_rewrite_line_pg(struct Map_info * Map,
   \todo Store original geometry in tmp table for restore
   \todo Store original geometry in tmp table for restore
   
   
   \param Map pointer to Map_info structure
   \param Map pointer to Map_info structure
-  \param type feature type  (GV_POINT, GV_LINE, ...)
   \param line feature id
   \param line feature id
+  \param type feature type  (GV_POINT, GV_LINE, ...)
   \param points feature geometry
   \param points feature geometry
   \param cats feature categories
   \param cats feature categories
   
   
   \return offset where feature was rewritten
   \return offset where feature was rewritten
   \return -1 on error
   \return -1 on error
 */
 */
-off_t V2_rewrite_line_pg(struct Map_info *Map, int line, int type,
+off_t V2_rewrite_line_pg(struct Map_info *Map, off_t line, int type,
                          const struct line_pnts *points, const struct line_cats *cats)
                          const struct line_pnts *points, const struct line_cats *cats)
 {
 {
     G_debug(3, "V2_rewrite_line_pg(): line=%d type=%d",
     G_debug(3, "V2_rewrite_line_pg(): line=%d type=%d",
-            line, type);
+            (int)line, type);
 #ifdef HAVE_POSTGRES
 #ifdef HAVE_POSTGRES
     const char *schema_name, *table_name, *keycolumn;
     const char *schema_name, *table_name, *keycolumn;
     char *stmt, *geom_data;
     char *stmt, *geom_data;
@@ -233,13 +233,13 @@ off_t V2_rewrite_line_pg(struct Map_info *Map, int line, int type,
     pg_info = &(Map->fInfo.pg);
     pg_info = &(Map->fInfo.pg);
   
   
     if (line < 1 || line > Map->plus.n_lines) {
     if (line < 1 || line > Map->plus.n_lines) {
-        G_warning(_("Attempt to access feature with invalid id (%d)"), line);
+        G_warning(_("Attempt to access feature with invalid id (%d)"), (int)line);
         return -1;
         return -1;
     }
     }
   
   
     Line = Map->plus.Line[line];
     Line = Map->plus.Line[line];
     if (Line == NULL) {
     if (Line == NULL) {
-        G_warning(_("Attempt to access dead feature %d"), line);
+        G_warning(_("Attempt to access dead feature %d"), (int)line);
         return -1;
         return -1;
     }
     }
     offset = Line->offset;
     offset = Line->offset;
@@ -282,7 +282,7 @@ off_t V2_rewrite_line_pg(struct Map_info *Map, int line, int type,
     G_free(geom_data);
     G_free(geom_data);
 
 
     if (Vect__execute_pg(pg_info->conn, stmt) == -1) {
     if (Vect__execute_pg(pg_info->conn, stmt) == -1) {
-        G_warning(_("Unable to rewrite feature %d"), line);
+        G_warning(_("Unable to rewrite feature %d"), (int)line);
         Vect__execute_pg(pg_info->conn, "ROLLBACK");
         Vect__execute_pg(pg_info->conn, "ROLLBACK");
         return -1;
         return -1;
     }
     }
@@ -369,7 +369,7 @@ int V1_delete_line_pg(struct Map_info *Map, off_t offset)
   \return 0 on success
   \return 0 on success
   \return -1 on error
   \return -1 on error
 */
 */
-int V2_delete_line_pg(struct Map_info *Map, int line)
+int V2_delete_line_pg(struct Map_info *Map, off_t line)
 {
 {
 #ifdef HAVE_POSTGRES
 #ifdef HAVE_POSTGRES
     int ret;
     int ret;
@@ -378,7 +378,7 @@ int V2_delete_line_pg(struct Map_info *Map, int line)
     pg_info = &(Map->fInfo.pg);
     pg_info = &(Map->fInfo.pg);
 
 
     if (line < 1 || line > Map->plus.n_lines) {
     if (line < 1 || line > Map->plus.n_lines) {
-        G_warning(_("Attempt to access feature with invalid id (%d)"), line);
+        G_warning(_("Attempt to access feature with invalid id (%d)"), (int)line);
         return -1;
         return -1;
     }
     }
     
     
@@ -393,13 +393,13 @@ int V2_delete_line_pg(struct Map_info *Map, int line)
         struct P_line *Line;
         struct P_line *Line;
         
         
         if (line < 1 || line > Map->plus.n_lines) {
         if (line < 1 || line > Map->plus.n_lines) {
-            G_warning(_("Attempt to access feature with invalid id (%d)"), line);
+            G_warning(_("Attempt to access feature with invalid id (%d)"), (int)line);
             return -1;
             return -1;
         }
         }
         
         
         Line = Map->plus.Line[line];
         Line = Map->plus.Line[line];
         if (!Line) {
         if (!Line) {
-            G_warning(_("Attempt to access dead feature %d"), line);
+            G_warning(_("Attempt to access dead feature %d"), (int)line);
             return -1;
             return -1;
         }
         }
 
 
@@ -450,7 +450,7 @@ int V2_delete_line_pg(struct Map_info *Map, int line)
                 pg_info->toposchema_name, table_name, keycolumn, (int)Line->offset);
                 pg_info->toposchema_name, table_name, keycolumn, (int)Line->offset);
         if (Vect__execute_pg(pg_info->conn, stmt) == -1) {
         if (Vect__execute_pg(pg_info->conn, stmt) == -1) {
             G_warning(_("Unable to delete feature (%s) %d"), keycolumn,
             G_warning(_("Unable to delete feature (%s) %d"), keycolumn,
-                      line);
+                      (int)line);
             Vect__execute_pg(pg_info->conn, "ROLLBACK");
             Vect__execute_pg(pg_info->conn, "ROLLBACK");
             return -1;
             return -1;
         }
         }

+ 7 - 8
lib/vector/Vlib/write_sfa.c

@@ -142,21 +142,20 @@ off_t V2_write_line_sfa(struct Map_info *Map, int type,
   \param Map pointer to Map_info structure
   \param Map pointer to Map_info structure
   \param line feature id to be rewritten
   \param line feature id to be rewritten
   \param type feature type (see V1_write_line_ogr() for supported types)
   \param type feature type (see V1_write_line_ogr() for supported types)
-  \param offset unused (kept for consistency)
   \param points pointer to line_pnts structure (feature geometry)
   \param points pointer to line_pnts structure (feature geometry)
   \param cats pointer to line_cats structure feature categories
   \param cats pointer to line_cats structure feature categories
   
   
-  \return offset where line was rewritten
+  \return feature index in offset array (related to pseudo-topology)
   \return -1 on error
   \return -1 on error
 */
 */
-off_t V2_rewrite_line_sfa(struct Map_info *Map, int line, int type,
+off_t V2_rewrite_line_sfa(struct Map_info *Map, off_t line, int type,
 			  const struct line_pnts *points, const struct line_cats *cats)
 			  const struct line_pnts *points, const struct line_cats *cats)
 {
 {
     G_debug(3, "V2_rewrite_line_sfa(): line=%d type=%d",
     G_debug(3, "V2_rewrite_line_sfa(): line=%d type=%d",
-	    line, type);
+	    (int)line, type);
 
 
     if (line < 1 || line > Map->plus.n_lines) {
     if (line < 1 || line > Map->plus.n_lines) {
-        G_warning(_("Attempt to access feature with invalid id (%d)"), line);
+        G_warning(_("Attempt to access feature with invalid id (%d)"), (int)line);
         return -1;
         return -1;
     }
     }
 
 
@@ -189,7 +188,7 @@ off_t V2_rewrite_line_sfa(struct Map_info *Map, int line, int type,
   \return 0 on success
   \return 0 on success
   \return -1 on error
   \return -1 on error
 */
 */
-int V2_delete_line_sfa(struct Map_info *Map, int line)
+int V2_delete_line_sfa(struct Map_info *Map, off_t line)
 {
 {
 #if defined HAVE_OGR || defined HAVE_POSTGRES
 #if defined HAVE_OGR || defined HAVE_POSTGRES
     int ret, i, type, first;
     int ret, i, type, first;
@@ -198,14 +197,14 @@ int V2_delete_line_sfa(struct Map_info *Map, int line)
     static struct line_cats *Cats = NULL;
     static struct line_cats *Cats = NULL;
     static struct line_pnts *Points = NULL;
     static struct line_pnts *Points = NULL;
 
 
-    G_debug(3, "V2_delete_line_sfa(): line = %d", line);
+    G_debug(3, "V2_delete_line_sfa(): line = %d", (int)line);
 
 
     type = first = 0;
     type = first = 0;
     Line = NULL;
     Line = NULL;
     plus = &(Map->plus);
     plus = &(Map->plus);
 
 
     if (line < 1 || line > Map->plus.n_lines) {
     if (line < 1 || line > Map->plus.n_lines) {
-        G_warning(_("Attempt to access feature with invalid id (%d)"), line);
+        G_warning(_("Attempt to access feature with invalid id (%d)"), (int)line);
         return -1;
         return -1;
     }
     }