View Ticket
Not logged in
Ticket Hash: eca2ccc2c116db6d04d4325880ea63165d665b19
Title: The tool 'exif_loader' creates a spatial-table that cannot be read by QGIS
Status: Closed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Resolution: Works_As_Designed
Last Modified: 2017-02-28 18:09:34
Version Found In: 4.4.0-dev
User Comments:
anonymous added on 2016-07-05 06:20:24:

When creating the TABLE 'ExifPhoto'
The Geometry is created as a BLOB
'exif_loader.c:checkExifTables'

    strcat (sql, "GpsGeometry BLOB, ");
This leads to the result, that the TABLE cannot be loaded into QGIS,
as reported by the user 'Roberto' About "Import EXIF photos"

Adding the following, after removing the line shown above, resolves this
    strcpy (sql,
	    "SELECT AddGeometryColumn('ExifPhoto', 'GpsGeometry', 4326, 'MULTIPOINT', 'XYZ')");
    ret = sqlite3_exec (handle, sql, NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "AddGeometryColumn 'ExifPhoto:GpsGeometry' error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  goto abort;
      }
    strcpy (sql,
	    "SELECT CreateSpatialIndex('ExifPhoto', 'GpsGeometry')");
    ret = sqlite3_exec (handle, sql, NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "CreateSpatialIndex 'ExifPhoto:GpsGeometry' error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  goto abort;
      }
when the 'DeclaredType' used here: 'exif_loader.c:updateExifTables'
    geom->DeclaredType = GAIA_MULTIPOINT;
is properly set, so that both GPSLatLong and GPSDESTLatLong are supported,
resolves this problem.


anonymous added on 2016-07-05 07:02:49:

To insure that 'geometry_columns_statistics' properly filled,

    UpdateLayerStatistics()
should be called beforé the database is closed.
   if (dir_path)
    cnt = load_dir (handle, dir_path, gps_only, metadata);
   else
    cnt = load_file (handle, file_path, gps_only, metadata);
   if (cnt > 0)
   { // geometry_columns_statistics
    char sql[1024];
    char *err_msg = NULL;
    strcpy (sql, "SELECT UpdateLayerStatistics()");
    ret = sqlite3_exec (handle, sql, NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
    {
     fprintf (stderr, "UpdateLayerStatistics() error: %s\n", err_msg);
     sqlite3_free (err_msg);
    }
   }
   ret = sqlite3_close (handle);


sandro added on 2017-02-28 18:09:34:
the exif_loader tool is explicitly intended to import "raw data", may be requiring few carefully planned post-processing activities.
in other words: it's an high-end tool intended for professionals and skilled users, not necessarily expected to be "simple" but surely expected to be flexible and unconstrained.

spatialite_gui recently introduced a new "Import GPS photos" wizard that implements a simpler mechanism for the same task that surely is best fit for average users.