Announcement

  •  » Requests
  •  » Longitude/Latitude Sanity Checking

#1 2019-01-20 21:11:24

farnwomt
Member
2019-01-20
2

Longitude/Latitude Sanity Checking

Hi

I am new to Piwigo and I was using it to import about 113,000 photos that I have taken over the years.

Unfortunately one of my photos happened to have some bad Longitude/Latitude data which was outside the valid range and caused a SQL error about number out of range.  Unfortunately the error was very vague, telling me only that there was a problem at line 2791 of the query, which wasn't shown because it only showed the first few lines of the query.

I would like to suggest that there should be some sanity checking of the GPS coordinates in the code.  It seems to me that something like ...

    if (count($gps_exif) == 4)
    {
      if (
        is_array($gps_exif['GPSLatitude'])  and in_array($gps_exif['GPSLatitudeRef'], array('S', 'N')) and
        is_array($gps_exif['GPSLongitude']) and in_array($gps_exif['GPSLongitudeRef'], array('W', 'E'))
        )
      {
        $result['latitude'] = parse_exif_gps_data($gps_exif['GPSLatitude'], $gps_exif['GPSLatitudeRef']);
        $result['longitude'] = parse_exif_gps_data($gps_exif['GPSLongitude'], $gps_exif['GPSLongitudeRef']);
        if ( $result['latitude'] > 90 || $result['latitude'] < -90 || $result['longitude'] > 180 || $result['longitude'] < -180 ) {
            unset($result['latitude']);
            unset($result['longitude']);
        }
      }
    }

should do the trick at around line 186.  Obviously my bit of code is just the final if statement and unset.


Piwigo version:
PHP version:
MySQL version:
Piwigo URL: http://

Offline

 

#2 2019-01-20 21:12:35

farnwomt
Member
2019-01-20
2

Re: Longitude/Latitude Sanity Checking

Sorry, I forgot to say in the file include/functions_metadata.inc.php

Offline

 
  •  » Requests
  •  » Longitude/Latitude Sanity Checking

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact