Skip to content

Commit

Permalink
Fixes #35 which adds colon to static label and clarifies units (degre…
Browse files Browse the repository at this point in the history
…es).

Fixes #36 which makes pinch/zoom of loaded image work again.
Fixes #37 where following link to maps could cause crash.
Tested loading/analyzing images from sd cards connected to devices.
Tested DNG images and determined that iOS/Swift libraries strip some
needed metadata during load thus preventing them from being properly
analyzed.
  • Loading branch information
rdkgit committed Apr 9, 2024
1 parent cf41cd2 commit c0d6414
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 38 deletions.
2 changes: 1 addition & 1 deletion DroneModels
Submodule DroneModels updated 1 files
+39 −9 droneModels.json
16 changes: 8 additions & 8 deletions OpenAthenaIOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@
isa = PBXGroup;
children = (
59BEF5E92AB61C3700D5A56D /* OpenAthenaIOSRelease.entitlements */,
59A2554C2AB4A5C5009EB5BC /* OpenAthenaIOS.entitlements */,
596E92782AA7B090003E35CD /* droneModels.json */,
597089DA2A3FD35600B5E1BF /* Cubic.swift */,
59A2554C2AB4A5C5009EB5BC /* OpenAthenaIOS.entitlements */,
597089DB2A3FD35600B5E1BF /* EGM96complete.bin */,
596E92782AA7B090003E35CD /* droneModels.json */,
597089DC2A3FD35600B5E1BF /* EGM96Geoid.swift */,
59DBFF0F2AD0C456003C4B33 /* FisheyeDistortionCorrector.swift */,
59DBFF112AD0C48A003C4B33 /* PerspectiveDistortionCorrector.swift */,
Expand Down Expand Up @@ -708,7 +708,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = OpenAthenaIOS/OpenAthenaIOS.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 787;
CURRENT_PROJECT_VERSION = 842;
DEVELOPMENT_TEAM = S9737SV7NZ;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = OpenAthenaIOS/Info.plist;
Expand All @@ -726,7 +726,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.50;
MARKETING_VERSION = 2.52;
NEW_SETTING = "";
PRODUCT_BUNDLE_IDENTIFIER = com.openathena.OpenAthenaIOS;
PRODUCT_NAME = OpenAthena;
Expand All @@ -745,7 +745,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = OpenAthenaIOS/OpenAthenaIOSRelease.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 787;
CURRENT_PROJECT_VERSION = 842;
DEVELOPMENT_TEAM = S9737SV7NZ;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = OpenAthenaIOS/Info.plist;
Expand All @@ -763,7 +763,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.50;
MARKETING_VERSION = 2.52;
NEW_SETTING = "";
PRODUCT_BUNDLE_IDENTIFIER = com.openathena.OpenAthenaIOS;
PRODUCT_NAME = OpenAthena;
Expand All @@ -781,7 +781,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 787;
CURRENT_PROJECT_VERSION = 842;
DEVELOPMENT_TEAM = S9737SV7NZ;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
Expand All @@ -801,7 +801,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 787;
CURRENT_PROJECT_VERSION = 842;
DEVELOPMENT_TEAM = S9737SV7NZ;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
version = "2.2">
version = "2.1">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
filePath = "OpenAthenaIOS/DroneImage.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "1353"
endingLineNumber = "1353"
startingLineNumber = "1357"
endingLineNumber = "1357"
landmarkName = "resolveTarget(dem:altReference:)"
landmarkType = "7">
</BreakpointContent>
Expand Down
7 changes: 5 additions & 2 deletions OpenAthenaIOS/AboutViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ class AboutViewController: UIViewController, UIScrollViewDelegate {
// we want
private func setTextViewText(htmlStr hString: String)
{
if let attribString = vc.htmlToAttributedString(fromHTML: hString) {
self.textView.attributedText = attribString
// re issue #37, run entire on dispatchqueue
DispatchQueue.main.async {
if let attribString = self.vc.htmlToAttributedString(fromHTML: hString) {
self.textView.attributedText = attribString
}
}
}

Expand Down
13 changes: 8 additions & 5 deletions OpenAthenaIOS/DebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class DebugViewController: UIViewController, UIScrollViewDelegate {

self.htmlString += "Coordinate system: \(app.settings.outputMode)<br>"
self.htmlString += "Units: \(app.settings.unitsMode)<br>"
self.htmlString += "Drone params date: \(vc.droneParams!.droneParamsDate ?? "unknown"))<br>"
self.htmlString += "Drone params date: \(vc.droneParams!.droneParamsDate ?? "unknown")<br>"
self.htmlString += "CCD data for \(vc.droneParams!.droneCCDParams.count) drones<br>"
self.htmlString += "Use CCD Info: \(app.settings.useCCDInfo)<br>"
self.htmlString += "EGM96 model loaded: \(EGM96Geoid.s_model_ok)<br>"
Expand Down Expand Up @@ -138,7 +138,7 @@ class DebugViewController: UIViewController, UIScrollViewDelegate {
var centerLat,centerLon : Double
(centerLat,centerLon) = vc.dem!.getCenter()

let urlStr = "https://maps.google.com/maps/search/?api=1&t=k&query=\(centerLat),\(centerLon)"
let urlStr = "https://www.google.com/maps/search/?api=1&t=k&query=\(centerLat),\(centerLon)"
self.htmlString += "<a href='\(urlStr)'>\(urlStr)</a><br>"
}
else {
Expand Down Expand Up @@ -167,7 +167,7 @@ class DebugViewController: UIViewController, UIScrollViewDelegate {
var lon = try self.vc.theDroneImage!.getLongitude()
self.htmlString += "Latitude: \(lat)<br>"
self.htmlString += "Longitude: \(lon)<br>"
let urlStr = "https://maps.google.com/maps/search/?api=1&t=k&query=\(lat),\(lon)"
let urlStr = "https://www.google.com/maps/search/?api=1&t=k&query=\(lat),\(lon)"
self.htmlString += "<a href='\(urlStr)'>\(urlStr)</a><br>"
try self.htmlString += "Make: \(vc.theDroneImage!.getCameraMake())<br>"
try self.htmlString += "Model: \(vc.theDroneImage!.getCameraModel())<br>"
Expand Down Expand Up @@ -330,8 +330,11 @@ class DebugViewController: UIViewController, UIScrollViewDelegate {
// we want
private func setTextViewText(htmlStr hString: String)
{
if let attribString = vc.htmlToAttributedString(fromHTML: hString) {
self.textView.attributedText = attribString
// re issue #37, run entire call on dispatchqueue main async
DispatchQueue.main.async {
if let attribString = self.vc.htmlToAttributedString(fromHTML: hString) {
self.textView.attributedText = attribString
}
}
}

Expand Down
14 changes: 10 additions & 4 deletions OpenAthenaIOS/DroneImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,13 @@ public class DroneImage {
// compass correction is merely to compensate for errors in drone's
// compass calibration

public func getGimbalYawDegree() throws -> Double {
public func getGimbalYawDegree() throws -> Double
{

var az: Double

print("getGimbalYawDegree starting")

if metaData == nil {
throw DroneImageError.NoMetaData
}
Expand All @@ -620,6 +623,7 @@ public class DroneImage {
}

if metaData!["drone-dji:GimbalYawDegree"] != nil {
print("getGimbalYawDegree: drone-dji:GimbalYawDegree present")
az = (metaData!["drone-dji:GimbalYawDegree"] as! NSString).doubleValue
if settings != nil {
print("Adding \(settings!.compassCorrection) to AZ")
Expand Down Expand Up @@ -1558,7 +1562,9 @@ public class DroneImage {

// parse XMP/XML data out of image throwing errors
// if encountered
public func parseXmpMetaData() throws {
public func parseXmpMetaData() throws
{
print("parseXmpMetaData: starting")

if rawData == nil {
xmpDataRead = false
Expand All @@ -1575,14 +1581,14 @@ public class DroneImage {
let beginRange = dataString.range(of: "<?xpacket begin")
let endRange = dataString.range(of: "<?xpacket end.*?>", options: .regularExpression)
if beginRange == nil || endRange == nil {
//print("parseXmpMetaData: did not find tags\n")
print("parseXmpMetaData: did not find tags\n")
throw DroneImageError.NoXmpMetaData
}
let startIndex = beginRange!.lowerBound
let endIndex = endRange!.upperBound
xmlString = String(dataString[startIndex..<endIndex])
print("XML doc length is \(xmlString!.count)")
//print("XML String to parse is \(xmlString!)")
print("XML String to parse is \(xmlString!)")

// xmlString gets consumed by parser; we should parse a copy of it
xmlStringCopy = xmlString
Expand Down
38 changes: 30 additions & 8 deletions OpenAthenaIOS/LoadCalculateViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class LoadCalculateViewController: UIViewController,

if vc.theDroneImage != nil {
imageView.image = vc.theDroneImage?.theImage
// mark the image as its already been selected previously
// re issue #35
markImagePixel(x_prop: vc.theDroneImage!.targetXprop, y_prop: vc.theDroneImage!.targetYprop)
}

contentView.addSubview(stackView)
Expand Down Expand Up @@ -140,6 +143,12 @@ class LoadCalculateViewController: UIViewController,

} // viewDidLoad

// re issue #36, don't forget this function so that we can pinch/zoom
// the image
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return contentView
}

// when view is set to appear, reset the htmlString
// if we go forward to calculate then back to selectImage,
// viewDidLoad may not be called again and then we
Expand All @@ -148,6 +157,8 @@ class LoadCalculateViewController: UIViewController,
{
super.viewWillAppear(animated)

print("LoadCalculateViewController: viewWillAppear starting")

// create a cursor on target sender and pass Athena settings
cotSender = CursorOnTargetSender(params: app.settings)

Expand Down Expand Up @@ -440,6 +451,8 @@ class LoadCalculateViewController: UIViewController,
{
var lat, lon: Double

print("getImageData: starting")

if vc.theDroneImage == nil {
return
}
Expand Down Expand Up @@ -486,9 +499,11 @@ class LoadCalculateViewController: UIViewController,
}
}
catch {
self.htmlString += "Drone altitude: \(error)<br>"
self.htmlString += "Drone altitude: \(error)<br>"
}

print("getImageData: done, going to setTextViewText")

// display the text finally!
setTextViewText(htmlStr: self.htmlString)

Expand All @@ -499,8 +514,13 @@ class LoadCalculateViewController: UIViewController,
// we want
private func setTextViewText(htmlStr hString: String)
{
if let attribString = vc.htmlToAttributedString(fromHTML: hString) {
self.textView.attributedText = attribString
// to avoid crashing due to NSInternalConsistencyException, don't set
// on calling thread; dispatch to main async
// re issue #37
DispatchQueue.main.async {
if let attribString = self.vc.htmlToAttributedString(fromHTML: hString) {
self.textView.attributedText = attribString
}
}
}

Expand Down Expand Up @@ -603,6 +623,8 @@ class LoadCalculateViewController: UIViewController,
// check for [ 0,0,0,0, 0,0,0,0, 0 ]
// internally, all distances/altitudes are in meters

print("resolveTarget returned \(target)")

if target == [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] {
print("doCalculations: target return values all zeros, returning")
setTextViewText(htmlStr: htmlString)
Expand All @@ -623,14 +645,12 @@ class LoadCalculateViewController: UIViewController,
target[8] = target[3] + offset

//let nearestAltStr = roundDigitsToString(val: target[4] + offset, precision: 6)

print("resolveTarget returned \(target)")


//htmlString += "<h2>Target Lat,Lon: \(latStr),\(lonStr)</h2><br>"

//htmlString += "Resolve target: \(target)<br>"
//let urlStr = "https://maps.../maps/@?api=1&map_action=map&center=\(target[1]),\(target[2])"
let urlStr = "https://maps.google.com/maps/search/?api=1&t=k&query=\(latStr),\(lonStr)"
let urlStr = "https://www.google.com/maps/search/?api=1&t=k&query=\(latStr),\(lonStr)"
htmlString += "<a href='\(urlStr)'><h2>Lat,Lon: \(latStr),\(lonStr)</h2></a><br>"
if app.settings.unitsMode == .Metric {
htmlString += "<h2>Alt: \(altStr)m</h2><br>"
Expand Down Expand Up @@ -685,7 +705,7 @@ class LoadCalculateViewController: UIViewController,

let mgrsStr = MGRSGeodetic.WGS84_MGRS1m(Lat: target[1],Lon: target[2],Alt: target[3])
//htmlString += "<h2>MGRS1m: \(mgrsStr)</h2><br>"
let urlStr = "https://maps.google.com/maps/search/?api=1&t=k&query=\(mgrsStr)"
let urlStr = "https://www.google.com/maps/search/?api=1&t=k&query=\(mgrsStr)"
htmlString += "<a href='\(urlStr)'><h2>MGRS1m: \(mgrsStr)</h2></a><br>"
if app.settings.unitsMode == .Metric {
htmlString += "<h2>Alt: \(altStr)m</h2><br>"
Expand Down Expand Up @@ -761,6 +781,8 @@ class LoadCalculateViewController: UIViewController,
htmlString += "Altitude: above ground<br>"
}

print("doCalculations: going to get image data")

getImageData()

setTextViewText(htmlStr: htmlString)
Expand Down
9 changes: 5 additions & 4 deletions OpenAthenaIOS/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SettingsViewController: UIViewController, UIScrollViewDelegate {
// set slider parameters; keep consistent with OAAndroid
newAZCorrection = app.settings.compassCorrection
newAZSliderValue = app.settings.compassSliderValue
azOffsetLabel.text = "Manual Azimuth Correction \(newAZCorrection)"
azOffsetLabel.text = "Manual Azimuth Correction: \(newAZCorrection) \u{00B0}"
azOffsetLabel.textAlignment = .center
//azOffsetValueLabel.text = "\(newAZCorrection)"
azOffsetSlider.minimumValue = 0.0
Expand Down Expand Up @@ -210,7 +210,7 @@ class SettingsViewController: UIViewController, UIScrollViewDelegate {
newAZCorrection = 0.0
azOffsetSlider.value = 100.0
//azOffsetValueLabel.text = "Manual Azimuth Correction: \(newAZCorrection)"
azOffsetLabel.text = "Manual Azimuth Correction: \(newAZCorrection)"
azOffsetLabel.text = "Manual Azimuth Correction: \(newAZCorrection) \u{00B0}"
}

// user changed value via slider
Expand All @@ -221,7 +221,8 @@ class SettingsViewController: UIViewController, UIScrollViewDelegate {
newAZCorrection = calculateAZCorrectionOffset(sliderValue: newAZSliderValue)
//correctionTextField.text = "Manual Azimuth Correction: \(newCompassCorrection)"
//azOffsetValueLabel.text = "\(newAZCorrection)"
azOffsetLabel.text = "Manual Azimuth Correction: \(newAZCorrection)"
// re issue #35, add colon and degree symbol
azOffsetLabel.text = "Manual Azimuth Correction: \(newAZCorrection) \u{00B0}"
}

// user changed value via text view
Expand Down Expand Up @@ -328,7 +329,7 @@ extension SettingsViewController: UIPickerViewDelegate {
// newCompassCorrection = app.settings.compassCorrection
// newCompassSliderValue = app.settings.compassSliderValue
// compassOffsetLabel.text = "Manual Azimuth Correction"
// compassOffsetValueLabel.text = "\(newCompassCorrection)"
// compassOffsetValueLabel.text = "\(newCompassCorrection) \u{00B0}"
// compassOffsetSlider.minimumValue = 0.0
// compassOffsetSlider.maximumValue = 200.0
// compassOffsetSlider.value = newCompassSliderValue
Expand Down
9 changes: 6 additions & 3 deletions OpenAthenaIOS/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import UIKit
class ViewController: UIViewController {

var app: AppDelegate = UIApplication.shared.delegate as! AppDelegate
var version: Double = 2.50
var version: Double = 2.52
@IBOutlet var textView: UITextView!
@IBOutlet var imageView: UIImageView!
var dem: DigitalElevationModel?
Expand Down Expand Up @@ -283,8 +283,11 @@ class ViewController: UIViewController {
// we want
private func setTextViewText(htmlStr hString: String)
{
if let attribString = htmlToAttributedString(fromHTML: hString) {
self.textView.attributedText = attribString
// re issue #37, run all of this on dispatchqueue main
DispatchQueue.main.async {
if let attribString = self.htmlToAttributedString(fromHTML: hString) {
self.textView.attributedText = attribString
}
}
}

Expand Down

0 comments on commit c0d6414

Please sign in to comment.