Don't perform any string operations on the variable when we assume it's the decimal...
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 20 Aug 2010 00:41:04 +0000 (20:41 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 20 Aug 2010 00:41:04 +0000 (20:41 -0400)
Just cast it outright, don't trim() or replace the ordinal indicators if present, the
cast operation will do that for us, and as a bonus, won't corrupt the value if it's in
a locale that doesn't use a decimal point for a decimal seperator.

Bug: 9180

framework/Image/lib/Horde/Image/Exif/Base.php

index 6180c45..8a13cd2 100644 (file)
@@ -103,12 +103,11 @@ abstract class Horde_Image_Exif_Base
         // According to EXIF standard, GPS data can be in the form of
         // dd/1 mm/1 ss/1 or as a decimal reprentation.
         if (!is_array($data)) {
-            // Assume a scalar is a decimal representation - but strip it of
-            // any stray characters that may be there.
-            return (double)trim(str_replace(array('N', 'S', 'E', 'W'),
-                                            array('', '', '', ''),
-                                            $data));
+            // Assume a scalar is a decimal representation. Cast it to a float
+            // which will get rid of any stray ordinal indicators. (N, S, etc...)
+            return (double)$data;
         }
+
         if ($data[0] == 0) {
             return 0;
         }