Opened 6 years ago

Closed 6 years ago

#2157 closed defect (fixed)

m.measure segfaults for unknown units

Reported by: annakrat Owned by: grass-dev@…
Priority: normal Milestone: 7.0.0
Component: LibGIS Version: svn-trunk
Keywords: units, m.measure Cc:
CPU: All Platform: All

Description

Module m.measure segfaults in case of unknown units. In this 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.

Attachments (1)

proj3.diff (891 bytes) - added by neteler 6 years ago.
check for metre, metres, kilometre, kilometres spelling, too

Download all attachments as: .zip

Change History (4)

comment:1 in reply to:  description ; Changed 6 years ago by neteler

Replying to 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.

Changed 6 years ago by neteler

Attachment: proj3.diff added

check for metre, metres, kilometre, kilometres spelling, too

comment:2 in reply to:  1 Changed 6 years ago by annakrat

Replying to neteler:

Replying to 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).

comment:3 Changed 6 years ago by annakrat

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.