[GRASS-dev] [GRASS GIS] #2157: m.measure segfaults for unknown units

#2157: m.measure segfaults for unknown units
------------------------------+---------------------------------------------
Reporter: annakrat | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: LibGIS | Version: svn-trunk
Keywords: units, m.measure | Platform: All
      Cpu: All |
------------------------------+---------------------------------------------
Module m.measure segfaults in case of unknown units. In this
[http://lists.osgeo.org/pipermail/grass-dev/2014-January/066780.html
discussion] the units in PROJ_UNITS file are defined as ''metre'' and
''metres'' and library function G_units gets stuck in a loop. So it's
actually the problem of G_units and not m.measure. This patch seems to fix
the problem but I am not sure if there are any side effects:

{{{
Index: lib/gis/proj3.c

--- lib/gis/proj3.c (revision 58561)
+++ lib/gis/proj3.c (working copy)
@@ -72,7 +72,7 @@
         else if (strcasecmp(name, "degree") == 0 || strcasecmp(name,
"degrees") == 0)
             units = U_DEGREES;
         else
- units = U_UNDEFINED;
+ units = U_UNKNOWN;
      }

      return G_get_units_name(units, plural, FALSE);

}}}

With this fix, the output of m.measure is:

{{{
Length: 1.882393 units
Area: 0.055245 square units
}}}
Of course, fixing the ''metres'' to ''meters'' helps, too.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2157&gt;
GRASS GIS <http://grass.osgeo.org>

#2157: m.measure segfaults for unknown units
------------------------------+---------------------------------------------
Reporter: annakrat | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: LibGIS | Version: svn-trunk
Keywords: units, m.measure | Platform: All
      Cpu: All |
------------------------------+---------------------------------------------

Comment(by neteler):

Replying to [ticket:2157 annakrat]:
> ... the units in PROJ_UNITS file are defined as ''metre'' and ''metres''

Wouldn't it be better to then also catch these two words?
Untested patch attached.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2157#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2157: m.measure segfaults for unknown units
------------------------------+---------------------------------------------
Reporter: annakrat | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: LibGIS | Version: svn-trunk
Keywords: units, m.measure | Platform: All
      Cpu: All |
------------------------------+---------------------------------------------

Comment(by annakrat):

Replying to [comment:1 neteler]:
> Replying to [ticket:2157 annakrat]:
> > ... the units in PROJ_UNITS file are defined as ''metre'' and
''metres''
>
> Wouldn't it be better to then also catch these two words?
> Untested patch attached.

That makes sense. I committed both changes (r58633).

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2157#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2157: m.measure segfaults for unknown units
-----------------------+----------------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: LibGIS | Version: svn-trunk
Resolution: fixed | Keywords: units, m.measure
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Changes (by annakrat):

  * status: new => closed
  * resolution: => fixed

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2157#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>