|
@@ -8,6 +8,7 @@
|
|
* Jachym Cepicky <jachym les-ejk.cz>, Markus Neteler <neteler itc.it>
|
|
* Jachym Cepicky <jachym les-ejk.cz>, Markus Neteler <neteler itc.it>
|
|
* Ivan Shevlakov: points support -p
|
|
* Ivan Shevlakov: points support -p
|
|
* Luca Delucchi: lines support -l, vertical breaks
|
|
* Luca Delucchi: lines support -l, vertical breaks
|
|
|
|
+ * Markus Metz: rewrite, hexagon creation
|
|
* PURPOSE:
|
|
* PURPOSE:
|
|
* COPYRIGHT: (C) 1999-2014 by the GRASS Development Team
|
|
* COPYRIGHT: (C) 1999-2014 by the GRASS Development Team
|
|
*
|
|
*
|
|
@@ -47,10 +48,11 @@ int main(int argc, char *argv[])
|
|
struct grid_description grid_info;
|
|
struct grid_description grid_info;
|
|
struct Cell_head window;
|
|
struct Cell_head window;
|
|
struct Map_info Map;
|
|
struct Map_info Map;
|
|
- struct Option *vectname, *grid, *coord, *box, *angle, *position_opt, *breaks;
|
|
|
|
|
|
+ struct Option *vectname, *grid, *coord, *box, *angle, *position_opt,
|
|
|
|
+ *breaks, *type_opt;
|
|
struct GModule *module;
|
|
struct GModule *module;
|
|
- struct Flag *points_fl, *line_fl;
|
|
|
|
- int points_p, line_p, output_type;
|
|
|
|
|
|
+ struct Flag *hex_flag, *hs_flag;
|
|
|
|
+ int otype, ptype, ltype;
|
|
char *desc;
|
|
char *desc;
|
|
|
|
|
|
struct line_pnts *Points;
|
|
struct line_pnts *Points;
|
|
@@ -69,7 +71,7 @@ int main(int argc, char *argv[])
|
|
G_add_keyword(_("geometry"));
|
|
G_add_keyword(_("geometry"));
|
|
G_add_keyword(_("grid"));
|
|
G_add_keyword(_("grid"));
|
|
G_add_keyword(_("point pattern"));
|
|
G_add_keyword(_("point pattern"));
|
|
- module->description = _("Creates a vector map of a user-defined grid of area, lines or points.");
|
|
|
|
|
|
+ module->description = _("Creates a vector map of a user-defined grid.");
|
|
|
|
|
|
vectname = G_define_standard_option(G_OPT_V_OUTPUT);
|
|
vectname = G_define_standard_option(G_OPT_V_OUTPUT);
|
|
vectname->key = "map";
|
|
vectname->key = "map";
|
|
@@ -131,27 +133,42 @@ int main(int argc, char *argv[])
|
|
breaks->options = "0-60";
|
|
breaks->options = "0-60";
|
|
breaks->answer = "3";
|
|
breaks->answer = "3";
|
|
|
|
|
|
- points_fl = G_define_flag();
|
|
|
|
- points_fl->key = 'p';
|
|
|
|
- points_fl->description =
|
|
|
|
- _("Create grid of points instead of areas and centroids");
|
|
|
|
|
|
+ type_opt = G_define_standard_option(G_OPT_V_TYPE);
|
|
|
|
+ type_opt->options = "point,line,area";
|
|
|
|
+ type_opt->answer = "area";
|
|
|
|
+ type_opt->multiple = NO;
|
|
|
|
+ type_opt->description = _("Output feature type");
|
|
|
|
|
|
- line_fl = G_define_flag();
|
|
|
|
- line_fl->key = 'l';
|
|
|
|
- line_fl->description =
|
|
|
|
- _("Create grid as lines, instead of areas");
|
|
|
|
|
|
+ hex_flag = G_define_flag();
|
|
|
|
+ hex_flag->key = 'h';
|
|
|
|
+ hex_flag->description =
|
|
|
|
+ _("Create hexagons (default: rectangles)");
|
|
|
|
+
|
|
|
|
+ hs_flag = G_define_flag();
|
|
|
|
+ hs_flag->key = 's';
|
|
|
|
+ hs_flag->description =
|
|
|
|
+ _("Enforce symmetric hexagons");
|
|
|
|
|
|
if (G_parser(argc, argv))
|
|
if (G_parser(argc, argv))
|
|
exit(EXIT_FAILURE);
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
- line_p = line_fl->answer;
|
|
|
|
- if (line_p) {
|
|
|
|
- output_type = GV_LINE;
|
|
|
|
- } else {
|
|
|
|
- output_type = GV_BOUNDARY;
|
|
|
|
|
|
+ otype = 0;
|
|
|
|
+ switch (type_opt->answer[0]) {
|
|
|
|
+ case 'p':
|
|
|
|
+ otype |= GV_POINT;
|
|
|
|
+ break;
|
|
|
|
+ case 'l':
|
|
|
|
+ otype |= GV_LINE;
|
|
|
|
+ break;
|
|
|
|
+ case 'a':
|
|
|
|
+ otype |= GV_CENTROID;
|
|
|
|
+ otype |= GV_BOUNDARY;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
- points_p = points_fl->answer;
|
|
|
|
|
|
+ ptype = (otype & GV_POINTS);
|
|
|
|
+ ltype = (otype & GV_LINES);
|
|
|
|
+
|
|
|
|
|
|
/* get the current window */
|
|
/* get the current window */
|
|
G_get_window(&window);
|
|
G_get_window(&window);
|
|
@@ -167,6 +184,7 @@ int main(int argc, char *argv[])
|
|
grid_info.num_cols = atoi(grid->answers[1]);
|
|
grid_info.num_cols = atoi(grid->answers[1]);
|
|
|
|
|
|
grid_info.angle = M_PI / 180 * atof(angle->answer);
|
|
grid_info.angle = M_PI / 180 * atof(angle->answer);
|
|
|
|
+ set_angle(grid_info.angle);
|
|
|
|
|
|
nbreaks = atoi(breaks->answer);
|
|
nbreaks = atoi(breaks->answer);
|
|
|
|
|
|
@@ -178,17 +196,16 @@ int main(int argc, char *argv[])
|
|
if (box->answer)
|
|
if (box->answer)
|
|
G_fatal_error(_("'box' and 'position=region' are exclusive options"));
|
|
G_fatal_error(_("'box' and 'position=region' are exclusive options"));
|
|
|
|
|
|
- if (grid_info.angle != 0.0)
|
|
|
|
- G_fatal_error(_("'angle' and 'position=region' are exclusive options"));
|
|
|
|
|
|
+ grid_info.west = window.west;
|
|
|
|
+ grid_info.south = window.south;
|
|
|
|
+ grid_info.east = window.east;
|
|
|
|
+ grid_info.north = window.north;
|
|
|
|
|
|
- grid_info.origin_x = window.west;
|
|
|
|
- grid_info.origin_y = window.south;
|
|
|
|
|
|
+ grid_info.width = (window.east - window.west) / grid_info.num_cols;
|
|
|
|
+ grid_info.height = (window.north - window.south) / grid_info.num_rows;
|
|
|
|
|
|
- grid_info.length = (window.east - window.west) / grid_info.num_cols;
|
|
|
|
- grid_info.width = (window.north - window.south) / grid_info.num_rows;
|
|
|
|
-
|
|
|
|
- G_debug(2, "x = %e y = %e l = %e w = %e", grid_info.origin_x,
|
|
|
|
- grid_info.origin_y, grid_info.length, grid_info.width);
|
|
|
|
|
|
+ G_debug(2, "x = %e y = %e w = %e h = %e", grid_info.west,
|
|
|
|
+ grid_info.south, grid_info.width, grid_info.height);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
if (!coord->answer)
|
|
if (!coord->answer)
|
|
@@ -198,31 +215,24 @@ int main(int argc, char *argv[])
|
|
G_fatal_error(_("'box' option missing"));
|
|
G_fatal_error(_("'box' option missing"));
|
|
|
|
|
|
if (!G_scan_easting
|
|
if (!G_scan_easting
|
|
- (coord->answers[0], &(grid_info.origin_x), window.proj))
|
|
|
|
- G_fatal_error(_("Invalid easting"));;
|
|
|
|
|
|
+ (coord->answers[0], &(grid_info.west), window.proj))
|
|
|
|
+ G_fatal_error(_("Invalid easting"));
|
|
if (!G_scan_northing
|
|
if (!G_scan_northing
|
|
- (coord->answers[1], &(grid_info.origin_y), window.proj))
|
|
|
|
- G_fatal_error(_("Invalid northing"));;
|
|
|
|
|
|
+ (coord->answers[1], &(grid_info.south), window.proj))
|
|
|
|
+ G_fatal_error(_("Invalid northing"));
|
|
|
|
|
|
if (!G_scan_resolution
|
|
if (!G_scan_resolution
|
|
- (box->answers[0], &(grid_info.length), window.proj))
|
|
|
|
- G_fatal_error(_("Invalid distance"));;
|
|
|
|
|
|
+ (box->answers[0], &(grid_info.width), window.proj))
|
|
|
|
+ G_fatal_error(_("Invalid width"));
|
|
if (!G_scan_resolution
|
|
if (!G_scan_resolution
|
|
- (box->answers[1], &(grid_info.width), window.proj))
|
|
|
|
- G_fatal_error(_("Invalid distance"));;
|
|
|
|
|
|
+ (box->answers[1], &(grid_info.height), window.proj))
|
|
|
|
+ G_fatal_error(_("Invalid height"));
|
|
|
|
|
|
|
|
+ grid_info.east = grid_info.west + grid_info.width * grid_info.num_cols;
|
|
|
|
+ grid_info.north = grid_info.south + grid_info.height * grid_info.num_rows;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /*
|
|
|
|
- * vector rows are the actual number of rows of vectors to make up the
|
|
|
|
- * entire grid. ditto for cols.
|
|
|
|
- */
|
|
|
|
- grid_info.num_vect_rows = grid_info.num_rows + 1;
|
|
|
|
- grid_info.num_vect_cols = grid_info.num_cols + 1;
|
|
|
|
-
|
|
|
|
- Points = Vect_new_line_struct();
|
|
|
|
- Cats = Vect_new_cats_struct();
|
|
|
|
- db_init_string(&sql);
|
|
|
|
|
|
+ grid_info.xo = (grid_info.east + grid_info.west) / 2.0;
|
|
|
|
+ grid_info.yo = (grid_info.north + grid_info.south) / 2.0;
|
|
|
|
|
|
/* Open output map */
|
|
/* Open output map */
|
|
if (0 > Vect_open_new(&Map, dig_file, 0)) {
|
|
if (0 > Vect_open_new(&Map, dig_file, 0)) {
|
|
@@ -243,92 +253,175 @@ 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);
|
|
db_set_error_handler_driver(Driver);
|
|
db_set_error_handler_driver(Driver);
|
|
|
|
+ db_init_string(&sql);
|
|
|
|
|
|
- if (grid_info.num_rows < 27 && grid_info.num_cols < 27) {
|
|
|
|
- sprintf(buf,
|
|
|
|
- "create table %s ( cat integer, row integer, col integer, "
|
|
|
|
- "rown varchar(1), coln varchar(1))", Fi->table);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- sprintf(buf,
|
|
|
|
- "create table %s ( cat integer, row integer, col integer)",
|
|
|
|
- Fi->table);
|
|
|
|
- }
|
|
|
|
- db_set_string(&sql, buf);
|
|
|
|
|
|
+ if (hex_flag->answer) {
|
|
|
|
|
|
- G_debug(1, "SQL: %s", db_get_string(&sql));
|
|
|
|
|
|
+ grid_info.num_vect_rows = 2 * grid_info.num_rows + 1;
|
|
|
|
+ grid_info.num_vect_cols = grid_info.num_cols;
|
|
|
|
|
|
- if (db_execute_immediate(Driver, &sql) != DB_OK) {
|
|
|
|
- G_fatal_error(_("Unable to create table: %s"), db_get_string(&sql));
|
|
|
|
- }
|
|
|
|
|
|
+ /* figure out hexagon radius */
|
|
|
|
+ grid_info.rstep = (grid_info.north - grid_info.south) /
|
|
|
|
+ (grid_info.num_rows * 2);
|
|
|
|
+ grid_info.rrad = grid_info.rstep * 2 / sqrt(3.0);
|
|
|
|
|
|
- if (db_create_index2(Driver, Fi->table, Fi->key) != DB_OK)
|
|
|
|
- G_warning(_("Unable to create index"));
|
|
|
|
|
|
+ grid_info.cstep = (grid_info.east - grid_info.west) /
|
|
|
|
+ (grid_info.num_cols + 1.0 / 3.0);
|
|
|
|
+ grid_info.crad = grid_info.cstep / 1.5;
|
|
|
|
|
|
- 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);
|
|
|
|
|
|
+ if (hs_flag->answer) {
|
|
|
|
+ if (grid_info.rrad > grid_info.crad) {
|
|
|
|
+ grid_info.rrad = grid_info.crad;
|
|
|
|
+ grid_info.rstep = grid_info.rrad * sqrt(3.0) / 2.0;
|
|
|
|
+ }
|
|
|
|
+ else if (grid_info.crad > grid_info.rrad) {
|
|
|
|
+ grid_info.crad = grid_info.rrad;
|
|
|
|
+ grid_info.cstep = grid_info.crad * 1.5;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- if (!points_p) {
|
|
|
|
- /* create areas */
|
|
|
|
- write_grid(&grid_info, &Map, nbreaks, output_type);
|
|
|
|
- }
|
|
|
|
|
|
+ grid_info.num_vect_rows = (grid_info.north - grid_info.south) /
|
|
|
|
+ grid_info.rstep - 0.5;
|
|
|
|
+ grid_info.num_vect_cols = (grid_info.east - grid_info.west -
|
|
|
|
+ grid_info.crad * 0.5) / grid_info.cstep;
|
|
|
|
|
|
- /* Create a grid of label points at the centres of the grid cells */
|
|
|
|
- G_verbose_message(_("Creating centroids..."));
|
|
|
|
|
|
+ if (grid_info.east - grid_info.west < 3.5 * grid_info.crad) {
|
|
|
|
+ G_fatal_error(_("Please use a higher resolution or a larger region"));
|
|
|
|
+ }
|
|
|
|
+ if (grid_info.north - grid_info.south < 3 * grid_info.rstep) {
|
|
|
|
+ G_fatal_error(_("Please use a higher resolution or a larger region"));
|
|
|
|
+ }
|
|
|
|
|
|
- /* Write out centroids and attributes */
|
|
|
|
- /* If the output id is lines it skips to add centroids and attributes
|
|
|
|
- TODO decide what to write in the attribute table
|
|
|
|
- */
|
|
|
|
- if (!line_p) {
|
|
|
|
- db_begin_transaction(Driver);
|
|
|
|
- attCount = 0;
|
|
|
|
- for (i = 0; i < grid_info.num_rows; ++i) {
|
|
|
|
- for (j = 0; j < grid_info.num_cols; ++j) {
|
|
|
|
- double x, y;
|
|
|
|
- const int point_type = points_p ? GV_POINT : GV_CENTROID;
|
|
|
|
-
|
|
|
|
- x = grid_info.origin_x + (0.5 + j) * grid_info.length;
|
|
|
|
- y = grid_info.origin_y + (0.5 + i) * grid_info.width;
|
|
|
|
-
|
|
|
|
- rotate(&x, &y, grid_info.origin_x, grid_info.origin_y,
|
|
|
|
- grid_info.angle);
|
|
|
|
-
|
|
|
|
- Vect_reset_line(Points);
|
|
|
|
- Vect_reset_cats(Cats);
|
|
|
|
-
|
|
|
|
- Vect_append_point(Points, x, y, 0.0);
|
|
|
|
- Vect_cat_set(Cats, 1, attCount + 1);
|
|
|
|
- Vect_write_line(&Map, point_type, Points, Cats);
|
|
|
|
-
|
|
|
|
- sprintf(buf, "insert into %s values ", Fi->table);
|
|
|
|
- if (db_set_string(&sql, buf) != DB_OK)
|
|
|
|
- G_fatal_error(_("Unable to fill attribute table"));
|
|
|
|
-
|
|
|
|
- if (grid_info.num_rows < 27 && grid_info.num_cols < 27) {
|
|
|
|
- sprintf(buf,
|
|
|
|
- "( %d, %d, %d, '%c', '%c' )",
|
|
|
|
- attCount + 1, grid_info.num_rows - i,
|
|
|
|
- j + 1, 'A' + grid_info.num_rows - i - 1, 'A' + j);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- sprintf(buf, "( %d, %d, %d )",
|
|
|
|
- attCount + 1, i + 1, j + 1);
|
|
|
|
- }
|
|
|
|
- if (db_append_string(&sql, buf) != DB_OK)
|
|
|
|
- G_fatal_error(_("Unable to fill attribute table"));
|
|
|
|
-
|
|
|
|
- G_debug(3, "SQL: %s", db_get_string(&sql));
|
|
|
|
-
|
|
|
|
- if (db_execute_immediate(Driver, &sql) != DB_OK) {
|
|
|
|
- G_fatal_error(_("Unable to insert new record: %s"),
|
|
|
|
|
|
+ sprintf(buf, "create table %s ( %s integer)", Fi->table, Fi->key);
|
|
|
|
+
|
|
|
|
+ db_set_string(&sql, buf);
|
|
|
|
+
|
|
|
|
+ G_debug(1, "SQL: %s", db_get_string(&sql));
|
|
|
|
+
|
|
|
|
+ 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, Fi->key) != DB_OK)
|
|
|
|
+ G_warning(_("Unable to create index"));
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ attCount = hexgrid(&grid_info, &Map, nbreaks, otype);
|
|
|
|
+
|
|
|
|
+ db_begin_transaction(Driver);
|
|
|
|
+
|
|
|
|
+ for (i = 1; i <= attCount; ++i) {
|
|
|
|
+
|
|
|
|
+ sprintf(buf, "insert into %s values ( %d )", Fi->table, i);
|
|
|
|
+ if (db_set_string(&sql, buf) != DB_OK)
|
|
|
|
+ G_fatal_error(_("Unable to fill attribute table"));
|
|
|
|
+
|
|
|
|
+ G_debug(3, "SQL: %s", db_get_string(&sql));
|
|
|
|
+ if (db_execute_immediate(Driver, &sql) != DB_OK) {
|
|
|
|
+ G_fatal_error(_("Unable to insert new record: %s"),
|
|
db_get_string(&sql));
|
|
db_get_string(&sql));
|
|
- }
|
|
|
|
- attCount++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ /*
|
|
|
|
+ * vector rows are the actual number of rows of vectors to make up the
|
|
|
|
+ * entire grid. ditto for cols.
|
|
|
|
+ */
|
|
|
|
+ grid_info.num_vect_rows = grid_info.num_rows + 1;
|
|
|
|
+ grid_info.num_vect_cols = grid_info.num_cols + 1;
|
|
|
|
+
|
|
|
|
+ Points = Vect_new_line_struct();
|
|
|
|
+ Cats = Vect_new_cats_struct();
|
|
|
|
+
|
|
|
|
+ if (grid_info.num_rows < 27 && grid_info.num_cols < 27) {
|
|
|
|
+ sprintf(buf,
|
|
|
|
+ "create table %s ( cat integer, row integer, col integer, "
|
|
|
|
+ "rown varchar(1), coln varchar(1))", Fi->table);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ sprintf(buf,
|
|
|
|
+ "create table %s ( cat integer, row integer, col integer)",
|
|
|
|
+ Fi->table);
|
|
|
|
+ }
|
|
|
|
+ db_set_string(&sql, buf);
|
|
|
|
+
|
|
|
|
+ G_debug(1, "SQL: %s", db_get_string(&sql));
|
|
|
|
+
|
|
|
|
+ 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, Fi->key) != DB_OK)
|
|
|
|
+ G_warning(_("Unable to create index"));
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ if (ltype) {
|
|
|
|
+ /* create areas */
|
|
|
|
+ write_grid(&grid_info, &Map, nbreaks, ltype);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* Create a grid of label points at the centres of the grid cells */
|
|
|
|
+ G_verbose_message(_("Creating centroids..."));
|
|
|
|
+
|
|
|
|
+ /* Write out centroids and attributes */
|
|
|
|
+ /* If the output id is lines it skips to add centroids and attributes
|
|
|
|
+ TODO decide what to write in the attribute table
|
|
|
|
+ */
|
|
|
|
+ if (ptype) {
|
|
|
|
+ db_begin_transaction(Driver);
|
|
|
|
+ attCount = 0;
|
|
|
|
+ for (i = 0; i < grid_info.num_rows; ++i) {
|
|
|
|
+ for (j = 0; j < grid_info.num_cols; ++j) {
|
|
|
|
+ double x, y;
|
|
|
|
+
|
|
|
|
+ x = grid_info.west + (0.5 + j) * grid_info.width;
|
|
|
|
+ y = grid_info.south + (0.5 + i) * grid_info.height;
|
|
|
|
+
|
|
|
|
+ rotate(&x, &y, grid_info.xo, grid_info.yo,
|
|
|
|
+ grid_info.angle);
|
|
|
|
+
|
|
|
|
+ Vect_reset_line(Points);
|
|
|
|
+ Vect_reset_cats(Cats);
|
|
|
|
+
|
|
|
|
+ Vect_append_point(Points, x, y, 0.0);
|
|
|
|
+ Vect_cat_set(Cats, 1, attCount + 1);
|
|
|
|
+ Vect_write_line(&Map, ptype, Points, Cats);
|
|
|
|
+
|
|
|
|
+ sprintf(buf, "insert into %s values ", Fi->table);
|
|
|
|
+ if (db_set_string(&sql, buf) != DB_OK)
|
|
|
|
+ G_fatal_error(_("Unable to fill attribute table"));
|
|
|
|
+
|
|
|
|
+ if (grid_info.num_rows < 27 && grid_info.num_cols < 27) {
|
|
|
|
+ sprintf(buf, "( %d, %d, %d, '%c', '%c' )",
|
|
|
|
+ attCount + 1, grid_info.num_rows - i,
|
|
|
|
+ j + 1, 'A' + grid_info.num_rows - i - 1, 'A' + j);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ sprintf(buf, "( %d, %d, %d )",
|
|
|
|
+ attCount + 1, i + 1, j + 1);
|
|
|
|
+ }
|
|
|
|
+ if (db_append_string(&sql, buf) != DB_OK)
|
|
|
|
+ G_fatal_error(_("Unable to fill attribute table"));
|
|
|
|
+
|
|
|
|
+ G_debug(3, "SQL: %s", db_get_string(&sql));
|
|
|
|
+
|
|
|
|
+ if (db_execute_immediate(Driver, &sql) != DB_OK) {
|
|
|
|
+ G_fatal_error(_("Unable to insert new record: %s"),
|
|
|
|
+ db_get_string(&sql));
|
|
|
|
+ }
|
|
|
|
+ attCount++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
db_commit_transaction(Driver);
|
|
db_commit_transaction(Driver);
|
|
|
|
|