Files
iOS/Sources/Shared/API/Models/Zone.swift
Zac West 4d9a530637 Reorganize files in repo, pull out build settings from pbxproj (#1140)
This is somewhat in prep of being able to make the project file generated, but also just organizes things into more concrete directory structures.

This pulls out _all_ of the build settings from the root level, and most from the target level, into xcconfigs.

The new directory structure looks like:

- Sources
  - App
    - (everything from HomeAssistant/)
  - WatchApp
  - Shared
  - MacBridge
  - Extensions
    - Intents
    - NotificationContent
    - NotificationService
    - Share
    - Today
    - Watch
    - Widgets
- Tests
  - App
  - UI
  - Shared

Somewhat intentionally, the file structure under these is not yet standardized/organized.

The project targets are now:

- App
- WatchApp
- Shared-iOS
- Shared-watchOS
- MacBridge
- Tests-App
- Tests-UI
- Tests-Shared
- Extension-Intents
- Extension-NotificationContent
- Extension-NotificationService
- Extension-Share
- Extension-Today
- Extension-Widget
- WatchExtension-Watch

This does not yet clean up resources vs. sources, nor does it handle some of the "it's in Sources/App but it's part of Shared" crossover directory issues.
2020-10-03 00:15:04 -07:00

60 lines
2.0 KiB
Swift

//
// ZoneComponent.swift
// HomeAssistant
//
// Created by Robbie Trencheny on 4/10/16.
// Copyright © 2016 Robbie Trencheny. All rights reserved.
//
import Foundation
import ObjectMapper
import CoreLocation
public class Zone: Entity {
@objc public dynamic var Latitude: Double = 0.0
@objc public dynamic var Longitude: Double = 0.0
@objc public dynamic var Radius: Double = 0.0
@objc public dynamic var TrackingEnabled = true
@objc public dynamic var enterNotification = true
@objc public dynamic var exitNotification = true
@objc public dynamic var isPassive = false
// Beacons
@objc public dynamic var UUID: String?
public var Major: Int?
public var Minor: Int?
// SSID
public var SSIDTrigger: [String]?
public var SSIDFilter: [String]?
public override func mapping(map: Map) {
super.mapping(map: map)
Latitude <- map["attributes.latitude"]
Longitude <- map["attributes.longitude"]
Radius <- map["attributes.radius"]
TrackingEnabled <- map["attributes.track_ios"]
UUID <- map["attributes.beacon.uuid"]
Major <- map["attributes.beacon.major"]
Minor <- map["attributes.beacon.minor"]
SSIDTrigger <- map["attributes.ssid_trigger"]
SSIDFilter <- map["attributes.ssid_filter"]
isPassive <- map["attributes.passive"]
}
public func locationCoordinates() -> CLLocationCoordinate2D {
return CLLocationCoordinate2D(latitude: CLLocationDegrees(self.Latitude),
longitude: CLLocationDegrees(self.Longitude))
}
public func location() -> CLLocation {
return CLLocation(coordinate: self.locationCoordinates(),
altitude: 0,
horizontalAccuracy: self.Radius,
verticalAccuracy: -1,
timestamp: Date())
}
}