Opened 11 years ago

Closed 11 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 11 years ago.
check for metre, metres, kilometre, kilometres spelling, too

Download all attachments as: .zip

Change History (4)

in reply to:  description ; comment:1 by neteler, 11 years ago

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.

by neteler, 11 years ago

Attachment: proj3.diff added

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

in reply to:  1 comment:2 by annakrat, 11 years ago

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 by annakrat, 11 years ago

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