Skip to content

Commit

Permalink
Resolution - GPS (#59)
Browse files Browse the repository at this point in the history
* fix resolution-gps

Signed-off-by: Marino Faggiana <[email protected]>

---------

Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana authored Feb 28, 2024
1 parent 7d61d28 commit 3c34cc5
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions Sources/NextcloudKit/NKModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ import SwiftyJSON
@objc public var userId = ""
@objc public var latitude: Double = 0
@objc public var longitude: Double = 0
@objc public var altitude: Double = 0
@objc public var height: Int = 0
@objc public var width: Int = 0

Expand Down Expand Up @@ -877,43 +878,41 @@ class NKDataFileXML: NSObject {
}

// NC27 -----
if let gps = propstat["d:prop", "nc:file-metadata-gps"].text,
let data = gps.data(using: .utf8),
let jsonDict = try? JSONSerialization.jsonObject(with: data) as? [String: Double],
let latitude = jsonDict["latitude"],
let longitude = jsonDict["longitude"] {
if let latitude = propstat["d:prop", "nc:file-metadata-gps", "latitude"].double {
file.latitude = latitude
}
if let longitude = propstat["d:prop", "nc:file-metadata-gps", "longitude"].double {
file.longitude = longitude
}
if let altitude = propstat["d:prop", "nc:file-metadata-gps", "altitude"].double {
file.altitude = altitude
}

if let resolution = propstat["d:prop", "nc:file-metadata-size"].text,
let data = resolution.data(using: .utf8),
let jsonDict = try? JSONSerialization.jsonObject(with: data) as? [String: Int],
let height = jsonDict["height"],
let width = jsonDict["width"] {
file.height = height
if let width = propstat["d:prop", "nc:file-metadata-size", "width"].int {
file.width = width
}
if let height = propstat["d:prop", "nc:file-metadata-size", "height"].int {
file.height = height
}
// ----------

// ----- NC28
if let gps = propstat["d:prop", "nc:metadata-photos-gps"].text,
let data = gps.data(using: .utf8),
let jsonDict = try? JSONSerialization.jsonObject(with: data) as? [String: Double],
let latitude = jsonDict["latitude"],
let longitude = jsonDict["longitude"] {
if let latitude = propstat["d:prop", "nc:metadata-photos-gps", "latitude"].double {
file.latitude = latitude
}
if let longitude = propstat["d:prop", "nc:metadata-photos-gps", "longitude"].double {
file.longitude = longitude
}
if let altitude = propstat["d:prop", "nc:metadata-photos-gps", "altitude"].double {
file.altitude = altitude
}

if let resolution = propstat["d:prop", "nc:metadata-photos-size"].text,
let data = resolution.data(using: .utf8),
let jsonDict = try? JSONSerialization.jsonObject(with: data) as? [String: Int],
let height = jsonDict["height"],
let width = jsonDict["width"] {
file.height = height
if let width = propstat["d:prop", "nc:metadata-photos-size", "width"].int {
file.width = width
}
if let height = propstat["d:prop", "nc:metadata-photos-size", "height"].int {
file.height = height
}
// ----------

if let livePhotoFile = propstat["d:prop", "nc:metadata-files-live-photo"].text {
Expand Down

0 comments on commit 3c34cc5

Please sign in to comment.