hi this is my first grass complete grass script in C. I was trying to
draw a rectangle around the map region. The script work very well but I
can not display the vector map.
Please can you help me to find my mistake.
/****************************************************************
*
* MODULE: v.rectangle
*
* AUTHOR(S): Neuba Danho F-R [email protected]
*
*
* PURPOSE: Draw rectangle arround the map region or vector.
*
* COPYRIGHT: (C) 2003-2007 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.
*
**************************************************************/
#include<grass/gis.h>
#include<grass/Vect.h>
#include <grass/dbmi.h>
int main(int argc, char *argv[])
{
struct Cell_head window;
struct line_pnts *Points;
struct line_cats *Cats;
struct Map_info Out;
struct Option *output;
struct field_info *Fin;
dbDriver *driver;
int i;
char *vect_name;
double north,south,east,west;
G_gisinit(argv[0]);
output=G_define_standard_option(G_OPT_V_OUTPUT);
output->key="output";
output->description="Enter output name";
output->required=YES;
output->type=TYPE_STRING;
G_get_window(&window);
north=window.north;
south=window.south;
east=window.east;
west=window.west;
if (G_parser(argc,argv))
exit(EXIT_FAILURE);
Points=Vect_new_line_struct();
Cats=Vect_new_cats_struct();
vect_name=output->answer;
Vect_reset_line(Points);
Vect_open_new(&Out,vect_name,WITHOUT_Z);
if (Vect_set_open_level(2))
G_fatal_error(_("Unable to set predetermined vector open level"));
Vect_append_point(Points,east,north-0.5,0);
Vect_append_point(Points,east,south-0.5,0);
Vect_append_point(Points,west,north-0.5,0);
Vect_append_point(Points,west,south-0.5,0);
Vect_write_line(&Out,GV_LINE,Points,Cats);
Fin = Vect_default_field_info(&Out, 1, NULL, GV_1TABLE);
driver = db_start_driver_open_database(Fin->driver, Fin->database);
G_debug(1,
"Field number:%d; Name:<%s>; Driver:<%s>; Database:<%s>; Table:<%s>; Key:<%s>;\n",
Fin->number, Fin->name, Fin->driver, Fin->database, Fin->table,
Fin->key);
Vect_build(&Out);
Vect_close(EXIT_SUCCESS);
}
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev