[GRASS-dev] [GRASS GIS] #2332: change r.horizon output names from "angle index" to "angle"

GRASS GIS trac at osgeo.org
Wed Jun 18 03:05:13 PDT 2014


#2332: change r.horizon output names from "angle index" to "angle"
-------------------------+--------------------------------------------------
 Reporter:  zarch        |       Owner:  grass-dev@…              
     Type:  enhancement  |      Status:  new                      
 Priority:  normal       |   Milestone:  7.1.0                    
Component:  Default      |     Version:  svn-trunk                
 Keywords:  r.horizon    |    Platform:  All                      
      Cpu:  All          |  
-------------------------+--------------------------------------------------

Comment(by zarch):

 Replying to [comment:5 wenzeslaus]:
 > Replying to [comment:2 zarch]:
 > > Replying to [comment:1 annakrat]:
 > > > I don't like the dot there, though, since it's not valid for
 > > > vector maps and that's a source of confusion then.
 > >
 > > I don't like either, but I don't see any better solution, do you?
 >
 > The only possibility I see is to replace this dot with an
 > underscore, too: h_06_5, h_07_0, h_07_5. But the names are
 > not so nice anymore but wouldn't use colon for hour neither
 > (h_06:30 vs h_06_30), so maybe the underscore is actually
 > quite good.

 Actually I don't like too much the idea of replace dot with underscore, we
 loose readability. To improve readability perhaps we can use two
 underscore as separator between basename and numbers, like:
 basename__006_5


 The other disadvantage is that instead of using the standard C format
 string like: "basename_%05.2f" to generate the name, we have to define a
 function to split the integer and the decimal part, and we have to take
 care if the number of decimals is 0, then we have to switch the format,
 something like:

 {{{
 void get_name(const char *basename, double number, size_t decimals, char
 *name)
 {
     double integer, decimal;
     integer = floor(number);
     if (decimals != 0){
         decimal = ((number - integer) * pow(10., (double)decimals));
         sprintf(name, "%s__%03d_%d", basename, (int)integer,
 (int)decimal);
     }
     else{
         sprintf(name, "%s__%03d", basename, (int)integer);
     }
 }
 }}}

 and then:

 {{{
 get_name("basename", 12.34567890, 2, name);  // => basename__012_34
 get_name("basename", 12.34567890, 0, name);  // => basename__012
 }}}

 If we choose this option, this function should be put somewhere in GRASS
 library because other modules like r.sun must be able to reproduce the
 same logic, moreover have a function that generate the name given the
 basename and number should make easier to maintain consistency over the
 grass modules.

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/2332#comment:6>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list