def get_coordinate(self, type='latitude'): """Get latitude or longitude of photo from EXIF :param str type: Type of coordinate to get. Either "latitude" or "longitude". :returns: float or None if not present in EXIF or a non-photo file """ if (not self.is_valid()): return None key = self.exif_map[type] exif = self.get_exif() if (key not in exif): return None try: # this is a hack to get the proper direction by negating the # values for S and W coords = exif[key].value return geolocation.dms_to_decimal( *coords, direction=exif[self.exif_map[self.d_coordinates[type]]].value) except KeyError: return None
def get_coordinate(self, type='latitude'): """Get latitude or longitude of photo from EXIF :param str type: Type of coordinate to get. Either "latitude" or "longitude". :returns: float or None if not present in EXIF or a non-photo file """ if(not self.is_valid()): return None key = self.exif_map[type] exif = self.get_exif() if(key not in exif): return None try: # this is a hack to get the proper direction by negating the # values for S and W coords = exif[key].value return geolocation.dms_to_decimal( *coords, direction=exif[self.exif_map[self.d_coordinates[type]]].value ) except KeyError: return None
def test_dms_to_decimal_negative_sign(): decimal = geolocation.dms_to_decimal(10, 20, 100, 'SW') assert helper.isclose(decimal, -10.3611111111) decimal = geolocation.dms_to_decimal(10, 20, 100, 'sw') assert helper.isclose(decimal, -10.3611111111)
def test_dms_to_decimal_positive_sign(): decimal = geolocation.dms_to_decimal(10, 20, 100, 'NE') assert helper.isclose(decimal, 10.3611111111) decimal = geolocation.dms_to_decimal(10, 20, 100, 'ne') assert helper.isclose(decimal, 10.3611111111)