Commit 6fc4f28b

mo khan <mo@mokhan.ca>
2014-06-01 20:45:20
store nil lat and long if no exif data is found.
1 parent 91c0838
Changed files (2)
app
services
infrastructure
spec
services
infrastructure
app/services/infrastructure/exif_parser.rb
@@ -2,8 +2,8 @@ class ExifParser
   def parse_geolocation_from(file)
     exif = EXIFR::JPEG.new(file)
     return [exif.gps.latitude, exif.gps.longitude] if exif.gps.present?
-    [0, 0]
+    [nil, nil]
   rescue EXIFR::MalformedJPEG
-    [0, 0]
+    [nil, nil]
   end
 end
spec/services/infrastructure/exif_parser_spec.rb
@@ -13,13 +13,13 @@ describe ExifParser do
 
   it "ignores png files" do
     latitude, longitude = subject.parse_geolocation_from(png_file)
-    latitude.should == 0
-    longitude.should == 0
+    latitude.should be_nil
+    longitude.should be_nil
   end
 
   it "ignores jpg files with no gps info" do
     latitude, longitude = subject.parse_geolocation_from(jpg_no_gps)
-    latitude.should == 0
-    longitude.should == 0
+    latitude.should be_nil
+    longitude.should be_nil
   end
 end