~meese/pantheon-photos/fix-1273847

« back to all changes in this revision

Viewing changes to src/db/PhotoTable.vala

  • Committer: madelynn-r-may
  • Date: 2014-09-11 02:45:29 UTC
  • Revision ID: madelynn.r.may@gmail.com-20140911024529-k1fjhjaxffgvnhw0
adds location search entry for setting gps markers and other fixes from review

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
    public bool metadata_dirty;
93
93
    public bool enhanced;
94
94
    public Gee.HashMap<string, KeyValueMap>? original_transforms;
 
95
    public LocationID location_id;
95
96
 
96
97
    // Currently selected developer (RAW only)
97
98
    public RawDeveloper developer;
149
150
                                 + "original_transforms TEXT, "
150
151
                                 + "has_gps INTEGER DEFAULT -1, "
151
152
                                 + "gps_lat REAL, "
152
 
                                 + "gps_lon REAL "
 
153
                                 + "gps_lon REAL, "
 
154
                                 + "location_id INTEGER DEFAULT -1"
153
155
                                 + ")", -1, out stmt);
154
156
        assert (res == Sqlite.OK);
155
157
 
185
187
                      "INSERT INTO PhotoTable (filename, width, height, filesize, timestamp, exposure_time, "
186
188
                      + "orientation, original_orientation, import_id, event_id, md5, thumbnail_md5, "
187
189
                      + "exif_md5, time_created, file_format, title, rating, editable_id, developer, "
188
 
                      + "comment, has_gps, gps_lat, gps_lon) "
189
 
                      + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
 
190
                      + "comment, has_gps, gps_lat, gps_lon, location_id) "
 
191
                      + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
190
192
                      -1, out stmt);
191
193
        assert (res == Sqlite.OK);
192
194
 
238
240
        assert (res == Sqlite.OK);
239
241
        res = stmt.bind_double (23, photo_row.gps_coords.longitude);
240
242
        assert (res == Sqlite.OK);
241
 
 
 
243
        res = stmt.bind_int64 (24, photo_row.location_id.id);
 
244
        assert (res == Sqlite.OK);
242
245
 
243
246
        res = stmt.step ();
244
247
        if (res != Sqlite.DONE) {
252
255
        photo_row.photo_id = PhotoID (db.last_insert_rowid ());
253
256
        photo_row.orientation = photo_row.master.original_orientation;
254
257
        photo_row.event_id = EventID ();
 
258
        photo_row.location_id = LocationID ();
255
259
        photo_row.time_created = (time_t) time_created;
256
260
        photo_row.flags = 0;
257
261
 
380
384
                      + "original_orientation, import_id, event_id, transformations, md5, thumbnail_md5, "
381
385
                      + "exif_md5, time_created, flags, rating, file_format, title, backlinks, "
382
386
                      + "time_reimported, editable_id, metadata_dirty, developer, develop_shotwell_id, "
383
 
                      + "develop_camera_id, develop_embedded_id, comment, enhanced, original_transforms, has_gps, gps_lat, gps_lon "
 
387
                      + "develop_camera_id, develop_embedded_id, comment, enhanced, original_transforms, "
 
388
                      + "has_gps, gps_lat, gps_lon, location_id "
384
389
                      + "FROM PhotoTable WHERE id=?",
385
390
                      -1, out stmt);
386
391
        assert (res == Sqlite.OK);
426
431
        row.gps_coords.has_gps = stmt.column_int (30);
427
432
        row.gps_coords.latitude = stmt.column_double (31);
428
433
        row.gps_coords.longitude = stmt.column_double (32);
 
434
        row.location_id.id = stmt.column_int64 (33);
 
435
 
429
436
        return row;
430
437
    }
431
438
 
436
443
                      + "original_orientation, import_id, event_id, transformations, md5, thumbnail_md5, "
437
444
                      + "exif_md5, time_created, flags, rating, file_format, title, backlinks, time_reimported, "
438
445
                      + "editable_id, metadata_dirty, developer, develop_shotwell_id, develop_camera_id, "
439
 
                      + "develop_embedded_id, comment, enhanced, original_transforms, has_gps, gps_lat, gps_lon  FROM PhotoTable",
 
446
                      + "develop_embedded_id, comment, enhanced, original_transforms, has_gps, gps_lat, gps_lon, "
 
447
                      + "location_id  FROM PhotoTable",
440
448
                      -1, out stmt);
441
449
        assert (res == Sqlite.OK);
442
450
 
479
487
            row.gps_coords.has_gps = stmt.column_int (31);
480
488
            row.gps_coords.latitude = stmt.column_double (32);
481
489
            row.gps_coords.longitude = stmt.column_double (33);
 
490
            row.location_id.id = stmt.column_int64 (34);
 
491
 
482
492
            all.add (row);
483
493
        }
484
494
 
498
508
                                 + "timestamp, exposure_time, orientation, original_orientation, import_id, event_id, "
499
509
                                 + "transformations, md5, thumbnail_md5, exif_md5, time_created, flags, rating, "
500
510
                                 + "file_format, title, editable_id, developer, develop_shotwell_id, develop_camera_id, "
501
 
                                 + "develop_embedded_id, comment, enhanced, original_transforms, has_gps, gps_lat, gps_lon) "
502
 
                                 + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
 
511
                                 + "develop_embedded_id, comment, enhanced, original_transforms, has_gps, gps_lat, gps_lon, location_id) "
 
512
                                 + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
503
513
                                 -1, out stmt);
504
514
        assert (res == Sqlite.OK);
505
515
 
564
574
        assert (res == Sqlite.OK);
565
575
        res = stmt.bind_double (30, original.gps_coords.longitude);
566
576
        assert (res == Sqlite.OK);
 
577
        res = stmt.bind_int64 (31, original.location_id.id);
 
578
        assert (res == Sqlite.OK);
567
579
 
568
580
        res = stmt.step ();
569
581
        if (res != Sqlite.DONE) {
758
770
        return update_int64_by_id (photo_id.id, "event_id", event_id.id);
759
771
    }
760
772
 
 
773
    public bool set_location (PhotoID photo_id, LocationID location_id) {
 
774
        return update_int64_by_id (photo_id.id, "location_id", location_id.id);
 
775
    }
 
776
 
761
777
    private string? get_raw_transformations (PhotoID photo_id) {
762
778
        Sqlite.Statement stmt;
763
779
        if (!select_by_id (photo_id.id, "transformations", out stmt))