Skip to content

Commit

Permalink
Merge pull request #4 from AlexCornforth/feature/planter_location
Browse files Browse the repository at this point in the history
Now uploading planter location
  • Loading branch information
AlexCornforth authored Aug 15, 2022
2 parents 449c467 + 1cf1847 commit e7fb97c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="18154" systemVersion="20D91" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="20086" systemVersion="21F79" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="LocationDataEntity" representedClassName="LocationDataEntity" syncable="YES" codeGenerationType="class">
<attribute name="accuracy" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
<attribute name="capturedAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
Expand All @@ -18,6 +18,8 @@
<attribute name="identifier" optional="YES" attributeType="String"/>
<attribute name="lastLoggedIn" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="lastName" optional="YES" attributeType="String"/>
<attribute name="latitude" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
<attribute name="longitude" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
<attribute name="organization" optional="YES" attributeType="String"/>
<attribute name="phoneNumber" optional="YES" attributeType="String"/>
<attribute name="uploaded" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
Expand All @@ -26,7 +28,9 @@
</entity>
<entity name="PlanterIdentification" representedClassName="PlanterIdentification" syncable="YES" codeGenerationType="class">
<attribute name="createdAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="latitude" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
<attribute name="localPhotoPath" optional="YES" attributeType="String"/>
<attribute name="longitude" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
<attribute name="photoURL" optional="YES" attributeType="String"/>
<attribute name="uuid" optional="YES" attributeType="String"/>
<relationship name="planter" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PlanterDetail" inverseName="identification" inverseEntity="PlanterDetail"/>
Expand Down
4 changes: 2 additions & 2 deletions Treetracker-Core.podspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Pod::Spec.new do |spec|
spec.name = "Treetracker-Core"
spec.version = "0.0.11"
spec.version = "0.0.12"
spec.license = { :type => "GNU", :file => "LICENSE" }
spec.homepage = "https://github.com/Greenstand/treetracker-ios-core"
spec.summary = "Greenstand Treetracker core library."
spec.platform = :ios, "11.0"
spec.authors = { "Alex Cornforth" => "alexcornforth@me.com" }
spec.swift_version = '5.0'
spec.source = { :git => "https://github.com/Greenstand/treetracker-ios-core.git", :tag => "v0.0.11" }
spec.source = { :git => "https://github.com/Greenstand/treetracker-ios-core.git", :tag => "v0.0.12" }
spec.source_files = "treetracker-core/**/*.{h,m,swift}"
spec.resources = "Resources/*"
spec.dependency "AWSS3", "2.16.0"
Expand Down
7 changes: 7 additions & 0 deletions treetracker-core/Models/Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ public protocol Location {
var horizontalAccuracy: Double { get }
var verticalAccuracy: Double { get }
}

public extension Location {

var isValid: Bool {
return latitude != 0.0 && longitude != 0.0
}
}
2 changes: 2 additions & 0 deletions treetracker-core/Models/PlanterCheckIn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public protocol PlanterCheckIn: AnyObject {
var photoURL: String? { get }
var planterDetail: Planter? { get }
var trees: NSSet? { get }
var latitude: Double { get }
var longitude: Double { get }
}

extension PlanterIdentification: PlanterCheckIn {
Expand Down
8 changes: 4 additions & 4 deletions treetracker-core/Services/Uploads/PlanterUploadService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ private extension PlanterIdentification {
}
return ImageUploadRequest(
jpegData: data,
latitude: 0.0,
longitude: 0.0,
latitude: latitude,
longitude: longitude,
uuid: uuid
)
}
Expand All @@ -203,8 +203,8 @@ private extension PlanterDetail {
organization: organization,
phone: phoneNumber,
email: email,
latitude: nil,
longitude: nil,
latitude: latitude,
longitude: longitude,
deviceIdentifier: "",
recordUUID: recordUUID,
imageURL: imageURL
Expand Down
14 changes: 12 additions & 2 deletions treetracker-core/Services/User/SelfieService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ import Foundation
public struct SelfieData {

let jpegData: Data

public init(jpegData: Data) {
let latitude: Double
let longitude: Double

public init(
jpegData: Data,
latitude: Double,
longitude: Double
) {
self.jpegData = jpegData
self.latitude = latitude
self.longitude = longitude
}
}

Expand Down Expand Up @@ -58,6 +66,8 @@ class LocalSelfieService: SelfieService {
identification.createdAt = Date()
identification.localPhotoPath = photoPath
identification.uuid = uuid
identification.latitude = data.latitude
identification.longitude = data.longitude

planter.addToIdentification(identification)

Expand Down
14 changes: 13 additions & 1 deletion treetracker-core/Services/User/SignUpService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@ public struct SignUpDetails {
let username: Username
let name: Name
let organization: Organization
let latitude: Double
let longitude: Double

public init(username: Username, name: Name, organization: Organization) {
public init(
username: Username,
name: Name,
organization: Organization,
latitude: Double,
longitude: Double
) {
self.username = username
self.name = name
self.organization = organization
self.latitude = latitude
self.longitude = longitude
}
}

Expand Down Expand Up @@ -51,6 +61,8 @@ class LocalSignUpService: SignUpService {
planterDetail.uploaded = false
planterDetail.identifier = signUpDetails.username.value
planterDetail.uuid = UUID().uuidString
planterDetail.latitude = signUpDetails.latitude
planterDetail.longitude = signUpDetails.longitude

do {
try coreDataManager.viewContext.save()
Expand Down

0 comments on commit e7fb97c

Please sign in to comment.