Skip to content
Permalink
Browse files

Rename method for consistency, fix dox

  • Loading branch information
nyalldawson committed Nov 8, 2018
1 parent 0eefd3e commit 8ae1880d38975afe5633bb4e4163db4608432a23
@@ -38,6 +38,8 @@ the elevation as a z value.
{
%Docstring
Extended image geotag details.

.. versionadded:: 3.6
%End

%TypeHeaderCode
@@ -50,7 +52,7 @@ Extended image geotag details.
double elevation;
};

static bool geotagImage( const QString &imagePath, const QgsPointXY &location, const GeoTagDetails &details = QgsExifTools::GeoTagDetails() );
static bool geoTagImage( const QString &imagePath, const QgsPointXY &location, const GeoTagDetails &details = QgsExifTools::GeoTagDetails() );
%Docstring
Writes geotags to the image at ``imagePath``.

@@ -59,6 +61,8 @@ The ``location`` argument indicates the GPS location to write to the image, as a
If desired, extended GPS tags (such as elevation) can be specified via the ``details`` argument.

Returns true if writing was successful.

.. seealso:: :py:func:`getGeoTag`
%End
};

@@ -192,7 +192,7 @@ QgsPoint QgsExifTools::getGeoTag( const QString &imagePath, bool &ok )
}
}

bool QgsExifTools::geotagImage( const QString &imagePath, const QgsPointXY &location, const GeoTagDetails &details )
bool QgsExifTools::geoTagImage( const QString &imagePath, const QgsPointXY &location, const GeoTagDetails &details )
{
try
{
@@ -49,6 +49,8 @@ class ANALYSIS_EXPORT QgsExifTools

/**
* Extended image geotag details.
* \ingroup analysis
* \since QGIS 3.6
*/
class GeoTagDetails
{
@@ -73,8 +75,10 @@ class ANALYSIS_EXPORT QgsExifTools
* If desired, extended GPS tags (such as elevation) can be specified via the \a details argument.
*
* Returns true if writing was successful.
*
* \see getGeoTag()
*/
static bool geotagImage( const QString &imagePath, const QgsPointXY &location, const GeoTagDetails &details = QgsExifTools::GeoTagDetails() );
static bool geoTagImage( const QString &imagePath, const QgsPointXY &location, const GeoTagDetails &details = QgsExifTools::GeoTagDetails() );
};

#endif // QGSEXIFTOOLS_H
@@ -49,8 +49,8 @@ def testGeoTags(self):
self.assertFalse(ok)

def testTagging(self):
self.assertFalse(QgsExifTools.geotagImage('', QgsPointXY(1, 2)))
self.assertFalse(QgsExifTools.geotagImage('not a path', QgsPointXY(1, 2)))
self.assertFalse(QgsExifTools.geoTagImage('', QgsPointXY(1, 2)))
self.assertFalse(QgsExifTools.geoTagImage('not a path', QgsPointXY(1, 2)))

src_photo = os.path.join(TEST_DATA_DIR, 'photos', 'notags.JPG')

@@ -60,14 +60,14 @@ def testTagging(self):
tmpFile.close()

shutil.copy(src_photo, tmpName)
self.assertTrue(QgsExifTools.geotagImage(tmpName, QgsPointXY(1.1, 3.3)))
self.assertTrue(QgsExifTools.geoTagImage(tmpName, QgsPointXY(1.1, 3.3)))
tag, ok = QgsExifTools.getGeoTag(tmpName)
self.assertTrue(ok)
self.assertEqual(tag.asWkt(6), 'Point (1.1 3.3)')
os.remove(tmpName)

shutil.copy(src_photo, tmpName)
self.assertTrue(QgsExifTools.geotagImage(tmpName, QgsPointXY(-1.1, -3.3)))
self.assertTrue(QgsExifTools.geoTagImage(tmpName, QgsPointXY(-1.1, -3.3)))
tag, ok = QgsExifTools.getGeoTag(tmpName)
self.assertTrue(ok)
self.assertEqual(tag.asWkt(6), 'Point (-1.1 -3.3)')
@@ -76,7 +76,7 @@ def testTagging(self):
shutil.copy(src_photo, tmpName)
deets = QgsExifTools.GeoTagDetails()
deets.elevation = 110.1
self.assertTrue(QgsExifTools.geotagImage(tmpName, QgsPointXY(1.1, 3.3), deets))
self.assertTrue(QgsExifTools.geoTagImage(tmpName, QgsPointXY(1.1, 3.3), deets))
tag, ok = QgsExifTools.getGeoTag(tmpName)
self.assertTrue(ok)
self.assertEqual(tag.asWkt(6), 'PointZ (1.1 3.3 110.1)')
@@ -85,7 +85,7 @@ def testTagging(self):
shutil.copy(src_photo, tmpName)
deets = QgsExifTools.GeoTagDetails()
deets.elevation = -110.1
self.assertTrue(QgsExifTools.geotagImage(tmpName, QgsPointXY(1.1, 3.3), deets))
self.assertTrue(QgsExifTools.geoTagImage(tmpName, QgsPointXY(1.1, 3.3), deets))
tag, ok = QgsExifTools.getGeoTag(tmpName)
self.assertTrue(ok)
self.assertEqual(tag.asWkt(6), 'PointZ (1.1 3.3 -110.1)')

0 comments on commit 8ae1880

Please sign in to comment.
You can’t perform that action at this time.