Skip to content

Commit

Permalink
Move deps to SPM and internal modules, rm carthage
Browse files Browse the repository at this point in the history
  • Loading branch information
e-001 committed May 5, 2023
1 parent 421cd9a commit f98bdea
Show file tree
Hide file tree
Showing 14 changed files with 563 additions and 195 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
StarryNight/
MathUtil/
SpaceTime/


# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
Expand Down
12 changes: 0 additions & 12 deletions Cartfile

This file was deleted.

11 changes: 0 additions & 11 deletions Cartfile.resolved

This file was deleted.

483 changes: 332 additions & 151 deletions Graviton.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"pins" : [
{
"identity" : "orderedset",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Weebly/OrderedSet",
"state" : {
"branch" : "master",
"revision" : "cfbf9f5d6a8579d819f02164a236aa3dae9a9fe3"
}
},
{
"identity" : "realm-cocoa",
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/realm-cocoa.git",
"state" : {
"revision" : "9266efac9ef0c79e4e64a2ba36162d8d922893d2",
"version" : "10.39.0"
}
},
{
"identity" : "realm-core",
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/realm-core.git",
"state" : {
"revision" : "f2a209b164194190b46747c7f5e36cb30fd5db71",
"version" : "13.10.0"
}
},
{
"identity" : "regex",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sharplet/Regex",
"state" : {
"revision" : "76c2b73d4281d77fc3118391877efd1bf972f515",
"version" : "2.1.1"
}
},
{
"identity" : "sqlite.swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stephencelis/SQLite.swift",
"state" : {
"revision" : "7a2e3cd27de56f6d396e84f63beefd0267b55ccb",
"version" : "0.14.1"
}
},
{
"identity" : "swiftybeaver",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SwiftyBeaver/SwiftyBeaver",
"state" : {
"revision" : "1080914828ef1c9ca9cd2bad50667b3d847dabff",
"version" : "2.0.0"
}
},
{
"identity" : "xlpagertabstrip",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nk-5/XLPagerTabStrip/",
"state" : {
"branch" : "support_spm",
"revision" : "6398d7b529e2baa2183a4a5382e6fcc9d27db08a"
}
}
],
"version" : 2
}
24 changes: 10 additions & 14 deletions Graviton.xcodeproj/xcshareddata/xcschemes/Graviton.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EFC2C6931D88D02F0031AA9C"
BuildableName = "Graviton.app"
BlueprintName = "Graviton"
ReferencedContainer = "container:Graviton.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand Down Expand Up @@ -59,17 +68,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EFC2C6931D88D02F0031AA9C"
BuildableName = "Graviton.app"
BlueprintName = "Graviton"
ReferencedContainer = "container:Graviton.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -91,8 +89,6 @@
ReferencedContainer = "container:Graviton.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
19 changes: 19 additions & 0 deletions Graviton/KelvinColor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// KelvinColor.h
// KelvinColor
//
// Created by Sihao Lu on 8/24/17.
// Copyright © 2017 Sihao. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for KelvinColor.
FOUNDATION_EXPORT double KelvinColorVersionNumber;

//! Project version string for KelvinColor.
FOUNDATION_EXPORT const unsigned char KelvinColorVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <KelvinColor/PublicHeader.h>


119 changes: 119 additions & 0 deletions Graviton/KelvinColor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
//
// KelvinColor.swift
// KelvinColor
//
// Created by Sihao Lu on 8/24/17.
// Copyright © 2017 Sihao. All rights reserved.
//

// Ported from https://raw.githubusercontent.com/neilbartlett/color-temperature/master/index.js

import Foundation
import UIKit

public extension UIColor {
/// Initialize color based on the Kelvin temperature
///
/// - Parameter kelvin: color temperature in degrees Kelvin
convenience init(temperature kelvin: Double) {
let temperature = kelvin / 100.0
var red, green, blue: Double

if (temperature < 66.0) {
red = 255
} else {
// a + b x + c Log[x] /.
// {a -> 351.97690566805693`,
// b -> 0.114206453784165`,
// c -> -40.25366309332127
//x -> (kelvin/100) - 55}
red = temperature - 55.0
red = 351.97690566805693 + 0.114206453784165 * red - 40.25366309332127 * log(red)
if red < 0 {
red = 0
}
if red > 255 {
red = 255
}
}

if (temperature < 66.0) {
// a + b x + c Log[x] /.
// {a -> -155.25485562709179`,
// b -> -0.44596950469579133`,
// c -> 104.49216199393888`,
// x -> (kelvin/100) - 2}
green = temperature - 2
green = -155.25485562709179 - 0.44596950469579133 * green + 104.49216199393888 * log(green)
if green < 0 {
green = 0
}
if green > 255 {
green = 255
}
} else {
// a + b x + c Log[x] /.
// {a -> 325.4494125711974`,
// b -> 0.07943456536662342`,
// c -> -28.0852963507957`,
// x -> (kelvin/100) - 50}
green = temperature - 50.0
green = 325.4494125711974 + 0.07943456536662342 * green - 28.0852963507957 * log(green)
if green < 0 {
green = 0
}
if green > 255 {
green = 255
}

}

if (temperature >= 66.0) {
blue = 255
} else {
if (temperature <= 20.0) {
blue = 0
} else {
// a + b x + c Log[x] /.
// {a -> -254.76935184120902`,
// b -> 0.8274096064007395`,
// c -> 115.67994401066147`,
// x -> kelvin/100 - 10}
blue = temperature - 10
blue = -254.76935184120902 + 0.8274096064007395 * blue + 115.67994401066147 * log(blue)
if blue < 0 {
blue = 0
}
if blue > 255 {
blue = 255
}
}
}

self.init(red: CGFloat(red / 255.0), green: CGFloat(green / 255.0), blue: CGFloat(blue / 255.0), alpha: 1)
}

var temperature: Double {
var temperature: Double = 0
var testRGB: UIColor
let epsilon: Double = 0.4
var minTemperature: Double = 1000
var maxTemperature: Double = 40000
while (maxTemperature - minTemperature > epsilon) {
temperature = (maxTemperature + minTemperature) / 2
testRGB = UIColor.init(temperature: temperature)
var testBlue: CGFloat = 0
var testRed: CGFloat = 0
testRGB.getRed(&testRed, green: nil, blue: &testBlue, alpha: nil)
var currentBlue: CGFloat = 0
var currentRed: CGFloat = 0
self.getRed(&currentRed, green: nil, blue: &currentBlue, alpha: nil)
if testBlue / testRed >= currentBlue / currentRed {
maxTemperature = temperature
} else {
minTemperature = temperature
}
}
return round(temperature)
}
}
1 change: 0 additions & 1 deletion Graviton/Observer/Scenes/ObserverScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import CoreLocation
import KelvinColor
import MathUtil
import OpenGLES
import Orbits
Expand Down
2 changes: 1 addition & 1 deletion Orbits/Models/CelestialBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ open class CelestialBody: Body, BoundedByGravity, CustomStringConvertible, Compa
return gravParam / gravConstant * 10e8
}

public let satellites = OrderedSet<Body>()
public var satellites = OrderedSet<Body>()

public var description: String {
return "CelestialBody: { naif: \(naifId), name: \(name), radius(m): \(radius), rotationPeriod(s): \(rotationPeriod), obliquity(radians): \(obliquity), gm: \(gravParam), hillSphere(m): \(String(describing: hillSphere))}"
Expand Down
6 changes: 4 additions & 2 deletions Orbits/Models/RiseTransitSetElevation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import SpaceTime
import MathUtil
import RealmSwift
import CoreLocation
import GeoQueries

/// This structure embeds the rise-transit-set info along with
/// maximum elevation in a sliding window that spans a day
Expand Down Expand Up @@ -70,7 +69,10 @@ extension RiseTransitSetElevation: ObserverLoadable {
let deltaT = Double(timeZone.secondsFromGMT()) / 86400
let startJd = modf(julianDay.value).0 + deltaT
let endJd = modf(julianDay.value).0 + 1 + deltaT
let results = try! realm.objects(RiseTransitSetInfo.self).filter("naifId == %@ AND jd BETWEEN {%@, %@}", naifId, startJd, endJd).filterGeoRadius(center: site.location.coordinate, radius: ObserverInfo.distanceTolerance, sortAscending: false)
let results = try! realm.objects(RiseTransitSetInfo.self).filter("naifId == %@ AND jd BETWEEN {%@, %@}", naifId, startJd, endJd)

//
// .filterGeoRadius(center: site.location.coordinate, radius: ObserverInfo.distanceTolerance, sortAscending: false)
return RiseTransitSetElevation(rts: Array(results), startJd: JulianDay(startJd), endJd: JulianDay(endJd))
}

Expand Down
4 changes: 3 additions & 1 deletion Orbits/Realm/CelestialBodyObserverInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2017 Ben Lu. All rights reserved.
//

import Realm
import RealmSwift
import SpaceTime

Expand Down Expand Up @@ -41,7 +42,8 @@ extension CelestialBodyObserverInfo: ObserverLoadable {
let realm = try! Realm()
let jdStart = julianDay - 60 * 30
let jdEnd = julianDay + 60 * 30
let results = try! realm.objects(CelestialBodyObserverInfo.self).filter("naifId == %@ AND jd BETWEEN {%@, %@}", naifId, jdStart.value, jdEnd.value).filterGeoRadius(center: site.location.coordinate, radius: ObserverInfo.distanceTolerance, sortAscending: true)
let results = try! realm.objects(CelestialBodyObserverInfo.self).filter("naifId == %@ AND jd BETWEEN {%@, %@}", naifId, jdStart.value, jdEnd.value)
// .filterGeoRadius(center: site.location.coordinate, radius: ObserverInfo.distanceTolerance, sortAscending: true)
let info = Array(results)
guard info.isEmpty == false else { return nil }
return info.reduce(info[0]) { (r1, r2) -> CelestialBodyObserverInfo in
Expand Down
2 changes: 1 addition & 1 deletion Orbits/Realm/ObserverInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import RealmSwift
import SpaceTime
import CoreLocation

public class ObserverInfo: Object {
public class ObserverInfo: RealmSwift.Object {
/// Distance tolerance in meters:
/// records within radius will be regarded
/// as referring to the same place.
Expand Down

0 comments on commit f98bdea

Please sign in to comment.