[GRASS-SVN] r67332 - grass/trunk/vector/v.in.lidar

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 22 11:29:55 PST 2015


Author: wenzeslaus
Date: 2015-12-22 11:29:55 -0800 (Tue, 22 Dec 2015)
New Revision: 67332

Added:
   grass/trunk/vector/v.in.lidar/attributes.c
   grass/trunk/vector/v.in.lidar/attributes.h
   grass/trunk/vector/v.in.lidar/lidar.c
   grass/trunk/vector/v.in.lidar/lidar.h
Modified:
   grass/trunk/vector/v.in.lidar/main.c
   grass/trunk/vector/v.in.lidar/projection.h
Log:
v.in.lidar: move most of db code out of main, separate lidar-related defs

Added: grass/trunk/vector/v.in.lidar/attributes.c
===================================================================
--- grass/trunk/vector/v.in.lidar/attributes.c	                        (rev 0)
+++ grass/trunk/vector/v.in.lidar/attributes.c	2015-12-22 19:29:55 UTC (rev 67332)
@@ -0,0 +1,242 @@
+/*
+ * attribute handling
+ *
+ * Copyright 2011-2015 by Markus Metz, and The GRASS Development Team
+ * Authors:
+ *  Markus Metz (v.in.lidar)
+ *  Vaclav Petras (move code to standalone functions)
+ *
+ * This program is free software licensed under the GPL (>=v2).
+ * Read the COPYING file that comes with GRASS for details.
+ *
+ */
+
+#include <liblas/capi/liblas.h>
+
+#include <grass/gis.h>
+#include <grass/glocale.h>
+#include <grass/vector.h>
+#include <grass/dbmi.h>
+
+#include "lidar.h"
+
+/*
+ * Caller must execute
+ * db_commit_transaction(driver);
+ * db_close_database_shutdown_driver(driver);
+ * when done.
+ */
+void create_table_for_lidar(struct Map_info *vector_map, const char *name,
+                            int layer, dbDriver ** db_driver,
+                            struct field_info **finfo, int have_time,
+                            int have_color)
+{
+    char buf[2000];
+    dbString sql;
+
+    db_init_string(&sql);
+
+    char *cat_col_name = GV_KEY_COLUMN;
+
+    struct field_info *Fi = Vect_default_field_info(vector_map, layer,
+                                                    NULL, GV_1TABLE);
+
+    Vect_map_add_dblink(vector_map, layer, name, Fi->table,
+                        cat_col_name, Fi->database, Fi->driver);
+
+    /* check available LAS info, depends on POINT DATA RECORD FORMAT [0-5] */
+    /* X (double),
+     * Y (double),
+     * Z (double),
+     * intensity (double),
+     * return number (int),
+     * number of returns (int),
+     * scan direction (int),
+     * flight line edge (int),
+     * classification type (char),
+     * class (char),
+     * time (double) (FORMAT 1, 3, 4, 5),
+     * scan angle rank (int),
+     * source ID (int),
+     * user data (char), ???
+     * red (int)  (FORMAT 2, 3, 5),
+     * green (int) (FORMAT 2, 3, 5),
+     * blue (int) (FORMAT 2, 3, 5)*/
+
+    /* Create table */
+    sprintf(buf, "create table %s (%s integer", Fi->table, cat_col_name);
+    db_set_string(&sql, buf);
+
+    /* x, y, z */
+    sprintf(buf, ", x_coord double precision");
+    db_append_string(&sql, buf);
+    sprintf(buf, ", y_coord double precision");
+    db_append_string(&sql, buf);
+    sprintf(buf, ", z_coord double precision");
+    db_append_string(&sql, buf);
+    /* intensity */
+    sprintf(buf, ", intensity integer");
+    db_append_string(&sql, buf);
+    /* return number */
+    sprintf(buf, ", return integer");
+    db_append_string(&sql, buf);
+    /* number of returns */
+    sprintf(buf, ", n_returns integer");
+    db_append_string(&sql, buf);
+    /* scan direction */
+    sprintf(buf, ", scan_dir integer");
+    db_append_string(&sql, buf);
+    /* flight line edge */
+    sprintf(buf, ", edge integer");
+    db_append_string(&sql, buf);
+    /* classification type */
+    sprintf(buf, ", cl_type varchar(20)");
+    db_append_string(&sql, buf);
+    /* classification class */
+    sprintf(buf, ", class varchar(40)");
+    db_append_string(&sql, buf);
+    /* GPS time */
+    if (have_time) {
+        sprintf(buf, ", gps_time double precision");
+        db_append_string(&sql, buf);
+    }
+    /* scan angle */
+    sprintf(buf, ", angle integer");
+    db_append_string(&sql, buf);
+    /* source id */
+    sprintf(buf, ", src_id integer");
+    db_append_string(&sql, buf);
+    /* user data */
+    sprintf(buf, ", usr_data integer");
+    db_append_string(&sql, buf);
+    /* colors */
+    if (have_color) {
+        sprintf(buf, ", red integer, green integer, blue integer");
+        db_append_string(&sql, buf);
+        sprintf(buf, ", GRASSRGB varchar(11)");
+        db_append_string(&sql, buf);
+    }
+
+    db_append_string(&sql, ")");
+    G_debug(3, "%s", db_get_string(&sql));
+
+    dbDriver *driver = db_start_driver_open_database(Fi->driver,
+                                                     Vect_subst_var
+                                                     (Fi->database,
+                                                      vector_map));
+
+    if (driver == NULL) {
+        G_fatal_error(_("Unable open database <%s> by driver <%s>"),
+                      Vect_subst_var(Fi->database, vector_map), Fi->driver);
+    }
+    db_set_error_handler_driver(driver);
+
+    if (db_execute_immediate(driver, &sql) != DB_OK) {
+        G_fatal_error(_("Unable to create table: '%s'"), db_get_string(&sql));
+    }
+
+    if (db_create_index2(driver, Fi->table, cat_col_name) != DB_OK)
+        G_warning(_("Unable to create index for table <%s>, key <%s>"),
+                  Fi->table, cat_col_name);
+
+    if (db_grant_on_table
+        (driver, Fi->table, DB_PRIV_SELECT, DB_GROUP | DB_PUBLIC) != DB_OK)
+        G_fatal_error(_("Unable to grant privileges on table <%s>"),
+                      Fi->table);
+
+    db_begin_transaction(driver);
+
+    *db_driver = driver;
+    *finfo = Fi;
+}
+
+
+void las_point_to_attributes(struct field_info *Fi, dbDriver * driver,
+                             int cat, LASPointH LAS_point, double x,
+                             double y, double z, int have_time,
+                             int have_color)
+{
+    static char buf[2000];
+    static dbString sql;
+
+    /* unfortunately we have to do allocation every time because
+     * we need to clean the string the first time
+     * if desired, we could rely on static variable being initialized
+     * to 0 (at least C99) which is what the function is currently doing */
+    db_init_string(&sql);
+
+    char class_flag;
+    int las_class_type, las_class;
+
+    /* use LASPoint_Validate (LASPointH hPoint) to check for
+     * return number, number of returns, scan direction, flight line edge,
+     * classification, scan angle rank */
+    sprintf(buf, "insert into %s values ( %d", Fi->table, cat);
+    db_set_string(&sql, buf);
+
+    /* x, y, z */
+    sprintf(buf, ", %f", x);
+    db_append_string(&sql, buf);
+    sprintf(buf, ", %f", y);
+    db_append_string(&sql, buf);
+    sprintf(buf, ", %f", z);
+    db_append_string(&sql, buf);
+    /* intensity */
+    sprintf(buf, ", %d", LASPoint_GetIntensity(LAS_point));
+    db_append_string(&sql, buf);
+    /* return number */
+    sprintf(buf, ", %d", LASPoint_GetReturnNumber(LAS_point));
+    db_append_string(&sql, buf);
+    /* number of returns */
+    sprintf(buf, ",  %d", LASPoint_GetNumberOfReturns(LAS_point));
+    db_append_string(&sql, buf);
+    /* scan direction */
+    sprintf(buf, ", %d", LASPoint_GetScanDirection(LAS_point));
+    db_append_string(&sql, buf);
+    /* flight line edge */
+    sprintf(buf, ",  %d", LASPoint_GetFlightLineEdge(LAS_point));
+    db_append_string(&sql, buf);
+    class_flag = LASPoint_GetClassification(LAS_point);
+    /* classification type int or char ? */
+    las_class_type = class_flag / 32;
+    sprintf(buf, ", \'%s\'", class_type[las_class_type].name);
+    db_append_string(&sql, buf);
+    /* classification class int or char ? */
+    las_class = class_flag % 32;
+    if (las_class > 13)
+        las_class = 13;
+    sprintf(buf, ", \'%s\'", class_val[las_class].name);
+    db_append_string(&sql, buf);
+    /* GPS time */
+    if (have_time) {
+        sprintf(buf, ", %f", LASPoint_GetTime(LAS_point));
+        db_append_string(&sql, buf);
+    }
+    /* scan angle */
+    sprintf(buf, ", %d", LASPoint_GetScanAngleRank(LAS_point));
+    db_append_string(&sql, buf);
+    /* source id */
+    sprintf(buf, ", %d", LASPoint_GetPointSourceId(LAS_point));
+    db_append_string(&sql, buf);
+    /* user data */
+    sprintf(buf, ", %d", LASPoint_GetUserData(LAS_point));
+    db_append_string(&sql, buf);
+    /* colors */
+    if (have_color) {
+        LASColorH LAS_color = LASPoint_GetColor(LAS_point);
+        int red = LASColor_GetRed(LAS_color);
+        int green = LASColor_GetGreen(LAS_color);
+        int blue = LASColor_GetBlue(LAS_color);
+
+        sprintf(buf, ", %d, %d, %d", red, green, blue);
+        db_append_string(&sql, buf);
+        sprintf(buf, ", \"%03d:%03d:%03d\"", red, green, blue);
+        db_append_string(&sql, buf);
+    }
+    db_append_string(&sql, " )");
+    G_debug(3, "%s", db_get_string(&sql));
+
+    if (db_execute_immediate(driver, &sql) != DB_OK) {
+        G_fatal_error(_("Cannot insert new row: %s"), db_get_string(&sql));
+    }
+}

Added: grass/trunk/vector/v.in.lidar/attributes.h
===================================================================
--- grass/trunk/vector/v.in.lidar/attributes.h	                        (rev 0)
+++ grass/trunk/vector/v.in.lidar/attributes.h	2015-12-22 19:29:55 UTC (rev 67332)
@@ -0,0 +1,32 @@
+
+/****************************************************************************
+ *
+ * MODULE:       v.in.lidar
+ * AUTHOR(S):    Vaclav Petras
+ * PURPOSE:      projection related functions
+ * COPYRIGHT:    (C) 2015 by the GRASS Development Team
+ *
+ *               This program is free software under the GNU General Public
+ *               License (>=v2). Read the COPYING file that comes with GRASS
+ *               for details.
+ *
+ *****************************************************************************/
+
+
+#ifndef GRASS_LIDAR_TO_ATTRIBUTES_H
+#define GRASS_LIDAR_TO_ATTRIBUTES_H
+
+struct field_info;
+struct dbDriver;                /* TODO: is this correct forward declaration? */
+
+void create_table_for_lidar(struct Map_info *vector_map, const char *name,
+                            int layer, dbDriver ** db_driver,
+                            struct field_info **finfo, int have_time,
+                            int have_color);
+
+void las_point_to_attributes(struct field_info *Fi, dbDriver * driver,
+                             int cat, LASPointH LAS_point, double x,
+                             double y, double z, int have_time,
+                             int have_color);
+
+#endif /* GRASS_LIDAR_TO_ATTRIBUTES_H */

Added: grass/trunk/vector/v.in.lidar/lidar.c
===================================================================
--- grass/trunk/vector/v.in.lidar/lidar.c	                        (rev 0)
+++ grass/trunk/vector/v.in.lidar/lidar.c	2015-12-22 19:29:55 UTC (rev 67332)
@@ -0,0 +1,41 @@
+
+/****************************************************************************
+ *
+ * MODULE:       v.in.lidar
+ * AUTHOR(S):    Vaclav Petras
+ * PURPOSE:      common lidar-related definitions
+ * COPYRIGHT:    (C) 2015 by the GRASS Development Team
+ *
+ *               This program is free software under the GNU General Public
+ *               License (>=v2). Read the COPYING file that comes with GRASS
+ *               for details.
+ *
+ *****************************************************************************/
+
+
+#include "lidar.h"
+
+struct class_table class_val[] = {
+    {0, "Created, never classified"},
+    {1, "Unclassified"},
+    {2, "Ground"},
+    {3, "Low Vegetation"},
+    {4, "Medium Vegetation"},
+    {5, "High Vegetation"},
+    {6, "Building"},
+    {7, "Low Point (noise)"},
+    {8, "Model Key-point (mass point)"},
+    {9, "Water"},
+    {10, "Reserved for ASPRS Definition"},
+    {11, "Reserved for ASPRS Definition"},
+    {12, "Overlap Points"},
+    {13 /* 13 - 31 */ , "Reserved for ASPRS Definition"},
+    {0, 0}
+};
+
+struct class_table class_type[] = {
+    {5, "Synthetic"},
+    {6, "Key-point"},
+    {7, "Withheld"},
+    {0, 0}
+};

Added: grass/trunk/vector/v.in.lidar/lidar.h
===================================================================
--- grass/trunk/vector/v.in.lidar/lidar.h	                        (rev 0)
+++ grass/trunk/vector/v.in.lidar/lidar.h	2015-12-22 19:29:55 UTC (rev 67332)
@@ -0,0 +1,69 @@
+
+/****************************************************************************
+ *
+ * MODULE:       v.in.lidar
+ * AUTHOR(S):    Vaclav Petras
+ * PURPOSE:      common lidar-related definitions
+ * COPYRIGHT:    (C) 2015 by the GRASS Development Team
+ *
+ *               This program is free software under the GNU General Public
+ *               License (>=v2). Read the COPYING file that comes with GRASS
+ *               for details.
+ *
+ *****************************************************************************/
+
+
+#ifndef GRASS_LIDAR_H
+#define GRASS_LIDAR_H
+
+#define LAS_ALL 0
+#define LAS_FIRST 1
+#define LAS_LAST 2
+#define LAS_MID 3
+
+/*
+ * ASPRS Standard LIDAR Point Classes
+ * Classification Value (bits 0:4) : Meaning
+ *      0 : Created, never classified
+ *      1 : Unclassified
+ *      2 : Ground
+ *      3 : Low Vegetation
+ *      4 : Medium Vegetation
+ *      5 : High Vegetation
+ *      6 : Building
+ *      7 : Low Point (noise)
+ *      8 : Model Key-point (mass point)
+ *      9 : Water
+ *     10 : Reserved for ASPRS Definition
+ *     11 : Reserved for ASPRS Definition
+ *     12 : Overlap Points
+ *  13-31 : Reserved for ASPRS Definition
+ */
+
+/* Classification Bit Field Encoding
+ * Bits | Field Name     | Description
+ *  0-4 | Classification | Standard ASPRS classification as defined in the
+ *                         above classification table.
+ *    5 | Synthetic      | If set then this point was created by a technique
+ *                         other than LIDAR collection such as digitized from
+ *                         a photogrammetric stereo model or by traversing
+ *                         a waveform.
+ *    6 | Key-point      | If set, this point is considered to be a model
+ *                         key-point and thus generally should not be withheld
+ *                         in a thinning algorithm.
+ *    7 | Withheld       | If set, this point should not be included in
+ *                         processing (synonymous with Deleted).
+ */
+
+/* keep the comments above in sync with the .c file */
+
+struct class_table
+{
+    int code;
+    char *name;
+};
+
+extern struct class_table class_val[];
+extern struct class_table class_type[];
+
+#endif /* GRASS_LIDAR_H */

Modified: grass/trunk/vector/v.in.lidar/main.c
===================================================================
--- grass/trunk/vector/v.in.lidar/main.c	2015-12-22 16:12:27 UTC (rev 67331)
+++ grass/trunk/vector/v.in.lidar/main.c	2015-12-22 19:29:55 UTC (rev 67332)
@@ -29,82 +29,15 @@
 
 #include "count_decimation.h"
 #include "projection.h"
+#include "lidar.h"
+#include "attributes.h"
 
 #ifndef MAX
 #  define MIN(a,b)      ((a<b) ? a : b)
 #  define MAX(a,b)      ((a>b) ? a : b)
 #endif
 
-#define LAS_ALL 0
-#define LAS_FIRST 1
-#define LAS_LAST 2
-#define LAS_MID 3
 
-/*
- * ASPRS Standard LIDAR Point Classes
- * Classification Value (bits 0:4) : Meaning
- *      0 : Created, never classified
- *      1 : Unclassified
- *      2 : Ground
- *      3 : Low Vegetation
- *      4 : Medium Vegetation
- *      5 : High Vegetation
- *      6 : Building
- *      7 : Low Point (noise)
- *      8 : Model Key-point (mass point)
- *      9 : Water
- *     10 : Reserved for ASPRS Definition
- *     11 : Reserved for ASPRS Definition
- *     12 : Overlap Points
- *  13-31 : Reserved for ASPRS Definition
- */
-
-/* Classification Bit Field Encoding
- * Bits | Field Name     | Description
- *  0-4 | Classification | Standard ASPRS classification as defined in the
- *                         above classification table.
- *    5 | Synthetic      | If set then this point was created by a technique
- *                         other than LIDAR collection such as digitized from
- *	                   a photogrammetric stereo model or by traversing
- *                         a waveform.
- *    6 | Key-point      | If set, this point is considered to be a model 
- *                         key-point and thus generally should not be withheld
- *                         in a thinning algorithm.
- *    7 | Withheld       | If set, this point should not be included in
- *                         processing (synonymous with Deleted).
-*/
-
-struct class_table
-{
-    int code;
-    char *name;
-};
-
-static struct class_table class_val[] = {
-    {0, "Created, never classified"},
-    {1, "Unclassified"},
-    {2, "Ground"},
-    {3, "Low Vegetation"},
-    {4, "Medium Vegetation"},
-    {5, "High Vegetation"},
-    {6, "Building"},
-    {7, "Low Point (noise)"},
-    {8, "Model Key-point (mass point)"},
-    {9, "Water"},
-    {10, "Reserved for ASPRS Definition"},
-    {11, "Reserved for ASPRS Definition"},
-    {12, "Overlap Points"},
-    {13 /* 13 - 31 */, "Reserved for ASPRS Definition"},
-    {0, 0}
-};
-
-static struct class_table class_type[] = {
-    {5, "Synthetic"},
-    {6, "Key-point"},
-    {7, "Withheld"},
-    {0, 0}
-};
-
 void print_lasinfo(LASHeaderH LAS_header, LASSRSH LAS_srs);
 
 int main(int argc, char *argv[])
@@ -138,7 +71,6 @@
     /* Attributes */
     struct field_info *Fi;
     dbDriver *driver;
-    dbString sql, strval;
     
     /* LAS */
     LASReaderH LAS_reader;
@@ -622,9 +554,6 @@
                          TRUE);
     }
 
-    db_init_string(&sql);
-    db_init_string(&strval);
-
     if (!outloc_opt->answer) {	/* Check if the map exists */
 	if (G_find_vector2(out_opt->answer, G_mapset())) {
 	    if (overwrite)
@@ -661,116 +590,8 @@
 
     /* Add DB link */
     if (!notab_flag->answer) {
-	char *cat_col_name = GV_KEY_COLUMN;
-
-	Fi = Vect_default_field_info(&Map, id_layer, NULL, GV_1TABLE);
-
-	Vect_map_add_dblink(&Map, id_layer, out_opt->answer, Fi->table,
-			    cat_col_name, Fi->database, Fi->driver);
-
-	/* check available LAS info, depends on POINT DATA RECORD FORMAT [0-5] */
-	/* X (double),
-	 * Y (double), 
-	 * Z (double), 
-	 * intensity (double), 
-	 * return number (int), 
-	 * number of returns (int),
-	 * scan direction (int),
-	 * flight line edge (int),
-	 * classification type (char),
-	 * class (char),
-	 * time (double) (FORMAT 1, 3, 4, 5),
-	 * scan angle rank (int),
-	 * source ID (int),
-	 * user data (char), ???
-	 * red (int)  (FORMAT 2, 3, 5),
-	 * green (int) (FORMAT 2, 3, 5),
-	 * blue (int) (FORMAT 2, 3, 5)*/
-	 
-	/* Create table */
-	sprintf(buf, "create table %s (%s integer", Fi->table,
-		cat_col_name);
-	db_set_string(&sql, buf);
-	
-	/* x, y, z */
-	sprintf(buf, ", x_coord double precision");
-	db_append_string(&sql, buf);
-	sprintf(buf, ", y_coord double precision");
-	db_append_string(&sql, buf);
-	sprintf(buf, ", z_coord double precision");
-	db_append_string(&sql, buf);
-	/* intensity */
-	sprintf(buf, ", intensity integer");
-	db_append_string(&sql, buf);
-	/* return number */
-	sprintf(buf, ", return integer");
-	db_append_string(&sql, buf);
-	/* number of returns */
-	sprintf(buf, ", n_returns integer");
-	db_append_string(&sql, buf);
-	/* scan direction */
-	sprintf(buf, ", scan_dir integer");
-	db_append_string(&sql, buf);
-	/* flight line edge */
-	sprintf(buf, ", edge integer");
-	db_append_string(&sql, buf);
-	/* classification type */
-	sprintf(buf, ", cl_type varchar(20)");
-	db_append_string(&sql, buf);
-	/* classification class */
-	sprintf(buf, ", class varchar(40)");
-	db_append_string(&sql, buf);
-	/* GPS time */
-	if (have_time) {
-	    sprintf(buf, ", gps_time double precision");
-	    db_append_string(&sql, buf);
-	}
-	/* scan angle */
-	sprintf(buf, ", angle integer");
-	db_append_string(&sql, buf);
-	/* source id */
-	sprintf(buf, ", src_id integer");
-	db_append_string(&sql, buf);
-	/* user data */
-	sprintf(buf, ", usr_data integer");
-	db_append_string(&sql, buf);
-	/* colors */
-	if (have_color) {
-	    sprintf(buf, ", red integer, green integer, blue integer");
-	    db_append_string(&sql, buf);
-	    sprintf(buf, ", GRASSRGB varchar(11)");
-	    db_append_string(&sql, buf);
-	}
-
-	db_append_string(&sql, ")");
-	G_debug(3, "%s", db_get_string(&sql));
-
-	driver =
-	    db_start_driver_open_database(Fi->driver,
-					  Vect_subst_var(Fi->database,
-							 &Map));
-	if (driver == NULL) {
-	    G_fatal_error(_("Unable open database <%s> by driver <%s>"),
-			  Vect_subst_var(Fi->database, &Map), Fi->driver);
-	}
-        db_set_error_handler_driver(driver);
-
-	if (db_execute_immediate(driver, &sql) != DB_OK) {
-	    G_fatal_error(_("Unable to create table: '%s'"),
-			  db_get_string(&sql));
-	}
-
-	if (db_create_index2(driver, Fi->table, cat_col_name) != DB_OK)
-	    G_warning(_("Unable to create index for table <%s>, key <%s>"),
-		      Fi->table, cat_col_name);
-
-	if (db_grant_on_table
-	    (driver, Fi->table, DB_PRIV_SELECT,
-	     DB_GROUP | DB_PUBLIC) != DB_OK)
-	    G_fatal_error(_("Unable to grant privileges on table <%s>"),
-			  Fi->table);
-
-	db_begin_transaction(driver);
+        create_table_for_lidar(&Map, out_opt->answer, id_layer, &driver,
+                               &Fi, have_time, have_color);
     }
 
     struct Map_info vector_mask;
@@ -937,81 +758,8 @@
 
 	/* Attributes */
 	if (!notab_flag->answer) {
-	    char class_flag;
-	    int las_class_type, las_class;
-
-	     /* use LASPoint_Validate (LASPointH hPoint) to check for
-	      * return number, number of returns, scan direction, flight line edge,
-	      * classification, scan angle rank */
-	    sprintf(buf, "insert into %s values ( %d", Fi->table, cat);
-	    db_set_string(&sql, buf);
-
-	    /* x, y, z */
-	    sprintf(buf, ", %f", x);
-	    db_append_string(&sql, buf);
-	    sprintf(buf, ", %f", y);
-	    db_append_string(&sql, buf);
-	    sprintf(buf, ", %f", z);
-	    db_append_string(&sql, buf);
-	    /* intensity */
-	    sprintf(buf, ", %d", LASPoint_GetIntensity(LAS_point));
-	    db_append_string(&sql, buf);
-	    /* return number */
-	    sprintf(buf, ", %d", LASPoint_GetReturnNumber(LAS_point));
-	    db_append_string(&sql, buf);
-	    /* number of returns */
-	    sprintf(buf, ",  %d", LASPoint_GetNumberOfReturns(LAS_point));
-	    db_append_string(&sql, buf);
-	    /* scan direction */
-	    sprintf(buf, ", %d",  LASPoint_GetScanDirection(LAS_point));
-	    db_append_string(&sql, buf);
-	    /* flight line edge */
-	    sprintf(buf, ",  %d", LASPoint_GetFlightLineEdge(LAS_point));
-	    db_append_string(&sql, buf);
-	    class_flag = LASPoint_GetClassification(LAS_point);
-	    /* classification type int or char ? */
-	    las_class_type = class_flag / 32;
-	    sprintf(buf, ", \'%s\'", class_type[las_class_type].name);
-	    db_append_string(&sql, buf);
-	    /* classification class int or char ? */
-	    las_class = class_flag % 32;
-	    if (las_class > 13)
-		las_class = 13;
-	    sprintf(buf, ", \'%s\'", class_val[las_class].name);
-	    db_append_string(&sql, buf);
-	    /* GPS time */
-	    if (have_time) {
-		sprintf(buf, ", %f", LASPoint_GetTime(LAS_point));
-		db_append_string(&sql, buf);
-	    }
-	    /* scan angle */
-	    sprintf(buf, ", %d", LASPoint_GetScanAngleRank(LAS_point));
-	    db_append_string(&sql, buf);
-	    /* source id */
-	    sprintf(buf, ", %d", LASPoint_GetPointSourceId(LAS_point));
-	    db_append_string(&sql, buf);
-	    /* user data */
-	    sprintf(buf, ", %d", LASPoint_GetUserData(LAS_point));
-	    db_append_string(&sql, buf);
-	    /* colors */
-	    if (have_color) {
-		LASColorH LAS_color = LASPoint_GetColor(LAS_point);
-		int red = LASColor_GetRed(LAS_color);
-		int green = LASColor_GetGreen(LAS_color);
-		int blue = LASColor_GetBlue(LAS_color);
-
-		sprintf(buf, ", %d, %d, %d", red, green, blue);
-		db_append_string(&sql, buf);
-		sprintf(buf, ", \"%03d:%03d:%03d\"", red, green, blue);
-		db_append_string(&sql, buf);
-	    }
-	    db_append_string(&sql, " )");
-	    G_debug(3, "%s", db_get_string(&sql));
-
-	    if (db_execute_immediate(driver, &sql) != DB_OK) {
-		G_fatal_error(_("Cannot insert new row: %s"),
-			      db_get_string(&sql));
-	    }
+        las_point_to_attributes(Fi, driver, cat, LAS_point, x, y, z,
+                                have_time, have_color);
 	}
 
         if (count_decimation_is_end(&count_decimation_control))

Modified: grass/trunk/vector/v.in.lidar/projection.h
===================================================================
--- grass/trunk/vector/v.in.lidar/projection.h	2015-12-22 16:12:27 UTC (rev 67331)
+++ grass/trunk/vector/v.in.lidar/projection.h	2015-12-22 19:29:55 UTC (rev 67332)
@@ -1,8 +1,8 @@
 /****************************************************************************
  *
- * MODULE:       v.decimate
+ * MODULE:       v.in.lidar
  * AUTHOR(S):    Vaclav Petras
- * PURPOSE:      Reduce the number of points in a vector map
+ * PURPOSE:      projection related functions
  * COPYRIGHT:    (C) 2015 by the GRASS Development Team
  *
  *               This program is free software under the GNU General Public



More information about the grass-commit mailing list