Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Jul 31, 2023
1 parent c06ed38 commit 6cc4ae3
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ internal static double GetXmpGeoData(List<Directory> allExifItems, string proper
RegexOptions.None, TimeSpan.FromMilliseconds(100));
if(split.Length != 2) continue;
latitudeString = split[0];
latitudeRef = latitudeLocal[latitudeLocal.Length-1].ToString();
latitudeRef = latitudeLocal[^1].ToString();
}

if ( string.IsNullOrWhiteSpace(latitudeString) ) return 0;
Expand Down
71 changes: 64 additions & 7 deletions starsky/starskytest/Services/ReadMeta_ExifReadTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -806,19 +806,76 @@ public void GetOrientationFromExifItem_8()
public void TestGetXmpGeoData()
{
// Arrange
var allExifItems = new List<Directory>();

const string xmpData = "<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.56'>\n" +
"<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n\n " +
"<rdf:Description rdf:about=''\n xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>\n" +
" <Iptc4xmpCore:CountryCode>ALB</Iptc4xmpCore:CountryCode>\n </rdf:Description>\n\n" +
" <rdf:Description rdf:about=''\n xmlns:exif='http://ns.adobe.com/exif/1.0/'>\n" +
" <exif:GPSAltitude>800796/527</exif:GPSAltitude>\n" +
" <exif:GPSAltitudeRef>0</exif:GPSAltitudeRef>\n" +
" <exif:GPSLatitude>42,27.7005N</exif:GPSLatitude>\n" +
" <exif:GPSLongitude>19,52.86888E</exif:GPSLongitude>\n" +
" </rdf:Description>\n\n <rdf:Description rdf:about=''\n" +
" xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>\n" +
" <photoshop:City>Valbone</photoshop:City>\n" +
" <photoshop:Country>Shqipëri</photoshop:Country>\n" +
" <photoshop:DateCreated>2023-06-29T11:21:36</photoshop:DateCreated>\n" +
" <photoshop:State>Kukes County</photoshop:State>\n </rdf:Description>" +
"\n\n</rdf:RDF>\n</x:xmpmeta>\n";

var xmpMeta = XmpMetaFactory.ParseFromString(xmpData);

var container = new List<Directory>();
var dir2 = new XmpDirectory();
dir2.Set(GpsDirectory.TagLatitude, "45.5602777778");
dir2.Set(GpsDirectory.TagLatitudeRef, "N");
allExifItems.Add(dir2);
dir2.SetXmpMeta(xmpMeta);
container.Add(dir2);

const string propertyPath = "exif:GPSLatitude";

// Act
var result = ReadMetaExif.GetXmpGeoData(container, propertyPath);

var propertyPath = "exif:GPSLatitude";
// Assert
Assert.AreEqual(42.461675, result, 0.0000000001);
}

[TestMethod]
public void TestGetXmpGeoData2()
{
// Arrange

const string xmpData = "<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.56'>\n" +
"<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n\n " +
"<rdf:Description rdf:about=''\n xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>\n" +
" <Iptc4xmpCore:CountryCode>ALB</Iptc4xmpCore:CountryCode>\n </rdf:Description>\n\n" +
" <rdf:Description rdf:about=''\n xmlns:exif='http://ns.adobe.com/exif/1.0/'>\n" +
" <exif:GPSAltitude>800796/527</exif:GPSAltitude>\n" +
" <exif:GPSAltitudeRef>0</exif:GPSAltitudeRef>\n" +
" <exif:GPSLatitude>42,27.7005N</exif:GPSLatitude>\n" +
" <exif:GPSLongitude>19,52.86888E</exif:GPSLongitude>\n" +
" </rdf:Description>\n\n <rdf:Description rdf:about=''\n" +
" xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>\n" +
" <photoshop:City>Valbone</photoshop:City>\n" +
" <photoshop:Country>Shqipëri</photoshop:Country>\n" +
" <photoshop:DateCreated>2023-06-29T11:21:36</photoshop:DateCreated>\n" +
" <photoshop:State>Kukes County</photoshop:State>\n </rdf:Description>" +
"\n\n</rdf:RDF>\n</x:xmpmeta>\n";

var xmpMeta = XmpMetaFactory.ParseFromString(xmpData);

var container = new List<Directory>();
var dir2 = new XmpDirectory();
dir2.SetXmpMeta(xmpMeta);
container.Add(dir2);

const string propertyPath = "exif:GPSLongitude";

// Act
var result = ReadMetaExif.GetXmpGeoData(allExifItems, propertyPath);
var result = ReadMetaExif.GetXmpGeoData(container, propertyPath);

// Assert
Assert.AreEqual(45.5602777778, result, 0.0000000001);
Assert.AreEqual(19.881148, result, 0.0000000001);
}
}
}

0 comments on commit 6cc4ae3

Please sign in to comment.