lib/geo_calc/extensions/string.rb in geo_calc-0.7.7 vs lib/geo_calc/extensions/string.rb in geo_calc-0.7.7.1
- old
+ new
@@ -28,16 +28,20 @@
def to_lat
raise "An empty String has no latitude" if self.empty?
s = geo_clean
raise GeoDirectionMisMatch, "Direction E and W signify longitude and thus can't be converted to latitude, was: #{self}" if s =~ /[W|E]$/
s = s.parse_dms if s.respond_to? :parse_dms
+ rescue GeoUnits::Converter::Dms::ParseError
+ ensure
s.to_f.to_lat
end
def to_lng
raise "An empty String has no latitude" if self.empty?
s = geo_clean
raise GeoDirectionMisMatch, "Direction N and S signify latitude and thus can't be converted to longitude, was: #{self}" if s =~ /[N|S]$/
s = s.parse_dms if s.respond_to? :parse_dms
+ rescue GeoUnits::Converter::Dms::ParseError
+ ensure
s.to_f.to_lng
end
end
\ No newline at end of file