summaryrefslogtreecommitdiff
blob: f15032fd7c77bd731862100427e82c5043c16d36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
From 7c945a5c9116325dad795dbe9682c2c4a4dea2d9 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Sun, 20 Aug 2023 18:57:43 +0200
Subject: [PATCH] Fix build with >=exiv2-0.28

Fixes https://github.com/dfandrich/gpscorrelate/issues/22

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 exif-gps.cpp | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/exif-gps.cpp b/exif-gps.cpp
index d464d62..71b46ef 100644
--- a/exif-gps.cpp
+++ b/exif-gps.cpp
@@ -44,6 +44,7 @@
 #include "exiv2/image.hpp"
 #include "exiv2/exif.hpp"
 #include "exiv2/error.hpp"
+#include "exiv2/version.hpp"
 
 #include "gpsstructure.h"
 #include "exif-gps.h"
@@ -97,7 +98,11 @@ int main(int argc, char* argv[])
 char* ReadExifDate(const char* File, int* IncludesGPS)
 {
 	// Open and read the file.
+#if EXIV2_TEST_VERSION(0, 28, 0)
+	Exiv2::Image::UniquePtr Image;
+#else
 	Exiv2::Image::AutoPtr Image;
+#endif
 
 	try {
 		Image = Exiv2::ImageFactory::open(File);
@@ -154,7 +159,11 @@ char* ReadExifData(const char* File, double* Lat, double* Long, double* Elev, in
 	// much more data than the last, specifically
 	// for display purposes. For the GUI version.
 	// Open and read the file.
+#if EXIV2_TEST_VERSION(0, 28, 0)
+	Exiv2::Image::UniquePtr Image;
+#else
 	Exiv2::Image::AutoPtr Image;
+#endif
 
 	try {
 		Image = Exiv2::ImageFactory::open(File);
@@ -273,7 +282,11 @@ char* ReadExifData(const char* File, double* Lat, double* Long, double* Elev, in
 
 		// Is the altitude below sea level? If so, negate the value.
 		GPSData = ExifRead["Exif.GPSInfo.GPSAltitudeRef"];
+#if EXIV2_TEST_VERSION(0, 28, 0)
+		if (GPSData.count() >= 1 && GPSData.toUint32() == 1)
+#else
 		if (GPSData.count() >= 1 && GPSData.toLong() == 1)
+#endif
 		{
 				// Negate the elevation.
 				*Elev = -*Elev;
@@ -292,7 +305,11 @@ char* ReadGPSTimestamp(const char* File, char* DateStamp, char* TimeStamp, int*
 	// much more data than the last, specifically
 	// for display purposes. For the GUI version.
 	// Open and read the file.
+#if EXIV2_TEST_VERSION(0, 28, 0)
+	Exiv2::Image::UniquePtr Image;
+#else
 	Exiv2::Image::AutoPtr Image;
+#endif
 
 	try {
 		Image = Exiv2::ImageFactory::open(File);
@@ -463,7 +480,11 @@ int WriteGPSData(const char* File, const struct GPSPoint* Point,
 	struct utimbuf utb;
 	if (NoChangeMtime)
 		stat(File, &statbuf);
+#if EXIV2_TEST_VERSION(0, 28, 0)
+	Exiv2::Image::UniquePtr Image;
+#else
 	Exiv2::Image::AutoPtr Image;
+#endif
 
 	try {
 		Image = Exiv2::ImageFactory::open(File);
@@ -493,7 +514,11 @@ int WriteGPSData(const char* File, const struct GPSPoint* Point,
 	// Do all the easy constant ones first.
 	// GPSVersionID tag: standard says it should be four bytes: 02 02 00 00
 	//  (and, must be present).
+#if EXIV2_TEST_VERSION(0, 28, 0)
+	Exiv2::Value::UniquePtr Value = Exiv2::Value::create(Exiv2::unsignedByte);
+#else
 	Exiv2::Value::AutoPtr Value = Exiv2::Value::create(Exiv2::unsignedByte);
+#endif
 	Value->read("2 2 0 0");
 	replace(ExifToWrite, Exiv2::ExifKey("Exif.GPSInfo.GPSVersionID"), Value.get());
 	// Datum: the datum of the measured data. The default is WGS-84.
@@ -643,7 +668,11 @@ int WriteFixedDatestamp(const char* File, time_t Time)
 	struct utimbuf utb;
 	stat(File, &statbuf);
 
+#if EXIV2_TEST_VERSION(0, 28, 0)
+	Exiv2::Image::UniquePtr Image;
+#else
 	Exiv2::Image::AutoPtr Image;
+#endif
 
 	try {
 		Image = Exiv2::ImageFactory::open(File);
@@ -672,7 +701,11 @@ int WriteFixedDatestamp(const char* File, time_t Time)
 	ExifToWrite.erase(ExifToWrite.findKey(Exiv2::ExifKey("Exif.GPSInfo.GPSDateStamp")));
 	ExifToWrite["Exif.GPSInfo.GPSDateStamp"] = ScratchBuf;
 
+#if EXIV2_TEST_VERSION(0, 28, 0)
+	Exiv2::Value::UniquePtr Value = Exiv2::Value::create(Exiv2::unsignedRational);
+#else
 	Exiv2::Value::AutoPtr Value = Exiv2::Value::create(Exiv2::unsignedRational);
+#endif
 	snprintf(ScratchBuf, sizeof(ScratchBuf), "%d/1 %d/1 %d/1",
 			TimeStamp.tm_hour, TimeStamp.tm_min,
 			TimeStamp.tm_sec);
@@ -705,7 +738,11 @@ int RemoveGPSExif(const char* File, int NoChangeMtime, int NoWriteExif)
 		stat(File, &statbuf);
 
 	// Open the file and start reading.
+#if EXIV2_TEST_VERSION(0, 28, 0)
+	Exiv2::Image::UniquePtr Image;
+#else
 	Exiv2::Image::AutoPtr Image;
+#endif
 	
 	try {
 		Image = Exiv2::ImageFactory::open(File);
-- 
2.41.0