[GRASS-dev] rsdriver and rsdatabase options for v.lrs.where?

William A. Perkins william.perkins at pnl.gov
Thu Jan 17 13:59:10 EST 2008


Hello,

Perhaps I'm being naive, but I don't understand why v.lrs.segment has
the rstable and rsdriver options but the other v.lrs.* commands don't.
I've attached a patch (against today's CVS) for v.lrs.where, that's
just a copy and paste from v.lrs.segment.  It seems to work for me,
i.e., I can run v.lrs.where in a mapset (and db) other than the one
where the LRS was created.

Please tell me why this is bad.

Thanks.

Bill

-- 
Bill Perkins
Pacific Northwest National Laboratory
Hydrology Group
P.O. Box 999 MSIN K9-36
Richland, Washington, USA  99352
voice: (509) 372-6131 fax: (509) 372-6089 email: william.perkins at pnl.gov
-------------- next part --------------
Index: vector/v.lrs/v.lrs.where/main.c
===================================================================
RCS file: /home/grass/grassrepository/grass6/vector/v.lrs/v.lrs.where/main.c,v
retrieving revision 1.7
diff -u -r1.7 main.c
--- vector/v.lrs/v.lrs.where/main.c	10 Aug 2007 14:49:54 -0000	1.7
+++ vector/v.lrs/v.lrs.where/main.c	17 Jan 2008 18:55:00 -0000
@@ -39,9 +39,10 @@
     double thresh, multip;
     struct Option *lines_opt, *points_opt;
     struct Option *lfield_opt, *pfield_opt;
-    struct Option *table_opt, *thresh_opt;
+    struct Option *driver_opt, *database_opt, *table_opt, *thresh_opt;
     struct GModule *module;
     char   *mapset;
+    char   *drv, *db;
     struct Map_info LMap, PMap;
     struct line_cats *LCats, *PCats; 
     struct line_pnts *LPoints, *PPoints;
@@ -74,6 +75,22 @@
     pfield_opt->answer = "1";
     pfield_opt->description = _("Point layer");
     
+    driver_opt = G_define_option() ;
+    driver_opt->key         = "rsdriver" ;
+    driver_opt->type        = TYPE_STRING ;
+    driver_opt->required    = NO; 
+    driver_opt->description = _("Driver name for reference system table");
+    if ( (drv=db_get_default_driver_name()) )
+	    driver_opt->answer = drv;
+    
+    database_opt = G_define_option() ;
+    database_opt->key         = "rsdatabase" ;
+    database_opt->type        = TYPE_STRING ;
+    database_opt->required    = NO; 
+    database_opt->description = _("Database name for reference system table");
+    if ( (db=db_get_default_database_name()) )
+	    database_opt->answer = db;
+    
     table_opt = G_define_option() ;
     table_opt->key         = "rstable" ;
     table_opt->type        = TYPE_STRING ;
@@ -118,8 +135,8 @@
     
     db_init_handle (&rshandle);
     db_init_string (&rsstmt);
-    rsdriver = db_start_driver(NULL);
-    db_set_handle (&rshandle, NULL, NULL);
+    rsdriver = db_start_driver(driver_opt->answer);
+    db_set_handle (&rshandle, database_opt->answer, NULL);
     if (db_open_database(rsdriver, &rshandle) != DB_OK)
         G_fatal_error(_("Unable to open database for reference table"));
 


More information about the grass-dev mailing list