Skip to content

Commit

Permalink
Rename method for consistency, fix dox
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 12, 2018
1 parent 0eefd3e commit 8ae1880
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
6 changes: 5 additions & 1 deletion python/analysis/auto_generated/raster/qgsexiftools.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ the elevation as a z value.
{
%Docstring
Extended image geotag details.

.. versionadded:: 3.6
%End

%TypeHeaderCode
Expand All @@ -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``.

Expand All @@ -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
};

Expand Down
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsexiftools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 5 additions & 1 deletion src/analysis/raster/qgsexiftools.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class ANALYSIS_EXPORT QgsExifTools

/**
* Extended image geotag details.
* \ingroup analysis
* \since QGIS 3.6
*/
class GeoTagDetails
{
Expand All @@ -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
12 changes: 6 additions & 6 deletions tests/src/python/test_qgsexiftools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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)')
Expand All @@ -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)')
Expand All @@ -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)')
Expand Down

0 comments on commit 8ae1880

Please sign in to comment.