Skip to content

Commit

Permalink
v7.6.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegournay committed Apr 3, 2023
1 parent d5fd378 commit cc239d7
Show file tree
Hide file tree
Showing 812 changed files with 41,666 additions and 20,475 deletions.
3,038 changes: 846 additions & 2,192 deletions OpenFlight/OpenFlight.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

This file was deleted.

10 changes: 10 additions & 0 deletions OpenFlight/OpenFlight.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion OpenFlight/OpenFlight/.gitkeep

This file was deleted.

67 changes: 41 additions & 26 deletions OpenFlight/OpenFlight/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import GroundSdk
import SwiftyUserDefaults
import CoreData
import ArcGIS
import Combine
import Pictor

// MARK: - Internal Enums
/// Constants for all missions.
Expand All @@ -50,16 +52,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// MARK: - Public Properties
var window: UIWindow?

lazy var persistentContainer: NSPersistentContainer = {
let container = PersistentContainer(name: "Model")
container.loadPersistentStores { _, error in
if let error = error {
fatalError("Unable to load persistent stores: \(error)")
}
}
return container
}()

// MARK: - Private Properties
/// Main coordinator of the application.
private var appCoordinator: AppCoordinator!
Expand All @@ -76,7 +68,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
UIDevice.current.isBatteryMonitoringEnabled = true
// ARCGIS KEY - Openflight
AGSArcGISRuntimeEnvironment.apiKey =
"put your key here (https://developers.arcgis.com/)"
"AAPK68aea864d0ab428f96ca87b1207f248fkidAHOOEgM-2pAf7AYMjkL9Wn0BtqWs_IvBPtSiu4JfOoYlkZ1Vl7Rl6rGAReckQ"

// Enable gsdk system log
ULog.redirectToSystemLog(enabled: true)
Expand All @@ -85,13 +77,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
groundSdk = AppDelegateSetup.sdkSetup()

ULog.i(.appDelegate, "Application start \(AppUtils.version)")
Defaults.applicationVersion = AppUtils.version

// Sets up Pictor
AppDelegateSetup.pictorSetup()

// Create instance of services
let missionsToLoadAtStart: [AirSdkMissionSignature] = [OFMissionSignatures.defaultMission,
OFMissionSignatures.helloWorld]

let services = Services.createInstance(variableAssetsService: VariableAssetsServiceImpl(),
persistentContainer: persistentContainer,
missionsToLoadAtStart: missionsToLoadAtStart,
dashboardUiProvider: DashboardUiProviderImpl())
self.services = services
Expand All @@ -103,8 +98,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
grabberViewModel = RemoteControlGrabberViewModel(zoomService: services.drone.zoomService,
gimbalTiltService: services.drone.gimbalTiltService)

setupFirmwareAndMissionsInteractor()

// Start AppCoordinator.
self.appCoordinator = AppCoordinator(services: services)
self.appCoordinator.start()
Expand All @@ -118,6 +111,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Keep screen on while app is running (Enable).
application.isIdleTimerDisabled = true

// Check for database update
self.services.databaseUpdateService.checkForUpdate()

NSSetUncaughtExceptionHandler { exception in
ULog.e(.appDelegate, "Uncaught exception \(exception). Backtrace: \(exception.callStackSymbols)")
}
Expand Down Expand Up @@ -149,11 +145,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

// MARK: - AirSdkMissionsSetupProtocol
extension AppDelegate: AirSdkMissionsSetupProtocol {
/// Sets up `FirmwareAndMissionsInteractor`
func setupFirmwareAndMissionsInteractor() {
FirmwareAndMissionsInteractor.shared.setup()
}

/// Add AirSdk missions to the HUD Panel.
func addMissionsToHUDPanel() {
services.missionsStore.add(missions: [FlightPlanMission(),
Expand All @@ -168,16 +159,12 @@ extension AppDelegate: AirSdkMissionsSetupProtocol {
/// to prevent from missing changes in other targets.

public class AppDelegateSetup {
static var cancellables = Set<AnyCancellable>()

/// Setup GroundSDK.
public static func sdkSetup() -> GroundSdk {
// Set optional config BEFORE starting GroundSdk
#if DEBUG
setenv("ULOG_LEVEL", "D", 1)
#else
if Bundle.main.isInHouseBuild {
setenv("ULOG_LEVEL", "D", 1)
}
#endif
AppUtils.setLogLevel()
ParrotDebug.smartStartLog()

// Activate DevToolbox.
Expand All @@ -189,4 +176,32 @@ public class AppDelegateSetup {
return GroundSdk()
}

public static func pictorSetup() {
PictorConfiguration.shared.userAgent = "\(AppInfoCore.appBundle)/\(AppInfoCore.appVersion) " +
"(\(UIDevice.current.systemName); \(UIDevice.identifier); \(UIDevice.current.systemVersion)) " +
"\(AppInfoCore.sdkBundle)/\(AppInfoCore.sdkVersion)"

let container = PersistentContainer(name: "Model")
container.loadPersistentStores { _, error in
if let error = error {
fatalError("Unable to load persistent stores: \(error)")
}
}
PictorConfiguration.shared.oldPersistentContainer = container

Pictor.shared.logPublisher
.sink { log in
switch log.level {
case .warning:
ULog.w(ULogTag(name: log.tag), log.message)
case .info:
ULog.i(ULogTag(name: log.tag), log.message)
case .debug:
ULog.d(ULogTag(name: log.tag), log.message)
case .error:
ULog.e(ULogTag(name: log.tag), log.message)
}
}
.store(in: &cancellables)
}
}
4 changes: 2 additions & 2 deletions OpenFlight/OpenFlight/ArcGIS/AGSMultipart+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ extension AGSGeometry {
/// - altitudeOffset: altitude offset to apply to envelope, in meters. Altitude off set should be nil if overlay is in drapedFlat.
///
/// - Returns: AGSEnvelope.
func envelopeWithMargin(_ marginFactor: Double = ArcGISStyle.envelopeMarginFactor,
altitudeOffset: Double? = nil) -> AGSEnvelope {
public func envelopeWithMargin(_ marginFactor: Double = ArcGISStyle.envelopeMarginFactor,
altitudeOffset: Double? = nil) -> AGSEnvelope {
let envelopeBuilder = AGSEnvelopeBuilder(envelope: extent)
envelopeBuilder.expand(byFactor: marginFactor)
if let altitudeOffset = altitudeOffset {
Expand Down
9 changes: 9 additions & 0 deletions OpenFlight/OpenFlight/ArcGIS/AGSPoint+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ import ArcGIS

/// Utility extension for `AGSPoint`.
public extension AGSPoint {

/// Returns true if the coordinate is valid.
/// Coordinate 0, 0 is assumed invalid here.
var isValid: Bool {
let coordinate = self.toCLLocationCoordinate2D()
return CLLocationCoordinate2DIsValid(coordinate)
&& (coordinate.latitude != 0.0 || coordinate.longitude != 0.0)
}

/// Creates a new point with given altitude.
///
/// - Parameters:
Expand Down
4 changes: 2 additions & 2 deletions OpenFlight/OpenFlight/ArcGIS/ArgGIS+Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import Foundation
/// Defines ArcGIS constants.
public enum ArcGISStyle {
/// Defines envelope margin, as dimension factor.
static let envelopeMarginFactor: Double = 1.2
public static let envelopeMarginFactor: Double = 1.0
/// Envelope margin factor for Flight Plan and Photogrammetry projects.
static let projectEnvelopeMarginFactor: Double = 1.5
public static let projectEnvelopeMarginFactor: Double = 1.5
/// Minimal envelope width, in degrees.
static let minEnvelopeWidth: Double = 0.0002
/// Minimal envelope height, in degrees.
Expand Down
Loading

0 comments on commit cc239d7

Please sign in to comment.