浏览代码

Don't write original line cat, if user requested to ignore CATs. Enhances https://trac.osgeo.org/grass/changeset/53273

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53275 15284696-431f-4ddb-bdfa-cd5b030d7da7
Maris Nartiss 12 年之前
父节点
当前提交
e6bbe74f22
共有 1 个文件被更改,包括 13 次插入4 次删除
  1. 13 4
      vector/v.to.points/main.c

+ 13 - 4
vector/v.to.points/main.c

@@ -53,15 +53,19 @@ void write_point(struct Map_info *Out, double x, double y, double z,
         Vect_cat_set(PCats, 2, point_cat);
         Vect_cat_set(PCats, 2, point_cat);
     }
     }
     else {
     else {
-        Vect_cat_set(PCats, 1, point_cat);
+        Vect_cat_set(PCats, 2, point_cat);
     }
     }
     Vect_write_line(Out, GV_POINT, PPoints, PCats);
     Vect_write_line(Out, GV_POINT, PPoints, PCats);
 
 
     /* Attributes */
     /* Attributes */
     if (!table) {
     if (!table) {
 	db_zero_string(&stmt);
 	db_zero_string(&stmt);
-	sprintf(buf, "insert into %s values ( %d, %d, %.15g )", Fi->table,
-		point_cat, line_cat, along);
+        if (line_cat > 0)
+            sprintf(buf, "insert into %s values ( %d, %d, %.15g )", Fi->table,
+                point_cat, line_cat, along);
+        else
+            sprintf(buf, "insert into %s values ( %d, %.15g )", Fi->table,
+                point_cat, along);
 	db_append_string(&stmt, buf);
 	db_append_string(&stmt, buf);
 
 
 	if (db_execute_immediate(driver, &stmt) != DB_OK) {
 	if (db_execute_immediate(driver, &stmt) != DB_OK) {
@@ -286,7 +290,12 @@ int main(int argc, char **argv)
 	    G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
 	    G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
 			  Fi->database, Fi->driver);
 			  Fi->database, Fi->driver);
 
 
-	sprintf(buf,
+	if (field == -1) 
+            sprintf(buf,
+                "create table %s ( cat int, along double precision )",
+                Fi->table);
+         else
+            sprintf(buf,
 		"create table %s ( cat int, lcat int, along double precision )",
 		"create table %s ( cat int, lcat int, along double precision )",
 		Fi->table);
 		Fi->table);
 	db_append_string(&stmt, buf);
 	db_append_string(&stmt, buf);