Reverse geocoding
This commit is contained in:
parent
c39971637d
commit
9bd3426f14
@ -17,7 +17,7 @@
|
|||||||
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
|
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
|
||||||
<BreakpointContent
|
<BreakpointContent
|
||||||
uuid = "CF01B44D-372B-4C78-A197-7FDEC607CE0E"
|
uuid = "CF01B44D-372B-4C78-A197-7FDEC607CE0E"
|
||||||
shouldBeEnabled = "Yes"
|
shouldBeEnabled = "No"
|
||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
scope = "1"
|
scope = "1"
|
||||||
@ -28,7 +28,7 @@
|
|||||||
BreakpointExtensionID = "Xcode.Breakpoint.SymbolicBreakpoint">
|
BreakpointExtensionID = "Xcode.Breakpoint.SymbolicBreakpoint">
|
||||||
<BreakpointContent
|
<BreakpointContent
|
||||||
uuid = "B15A9E9C-A0CD-4FC9-8E24-DD93FB1B677F"
|
uuid = "B15A9E9C-A0CD-4FC9-8E24-DD93FB1B677F"
|
||||||
shouldBeEnabled = "Yes"
|
shouldBeEnabled = "No"
|
||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
symbolName = "UITableViewAlertForLayoutOutsideViewHierarchy"
|
symbolName = "UITableViewAlertForLayoutOutsideViewHierarchy"
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
|
|
||||||
let config = Realm.Configuration(
|
let config = Realm.Configuration(
|
||||||
schemaVersion: 13,
|
schemaVersion: 14,
|
||||||
migrationBlock: { migration, oldSchemaVersion in
|
migrationBlock: { migration, oldSchemaVersion in
|
||||||
if oldSchemaVersion <= 3 {
|
if oldSchemaVersion <= 3 {
|
||||||
var numbers: [String] = []
|
var numbers: [String] = []
|
||||||
|
|||||||
@ -147,6 +147,7 @@ class CheckController: UIViewController, MaskedTextFieldDelegateListener, UITabl
|
|||||||
|
|
||||||
let eventSingle = event == nil ? self.getEvent() : Single.just(event!)
|
let eventSingle = event == nil ? self.getEvent() : Single.just(event!)
|
||||||
eventSingle
|
eventSingle
|
||||||
|
.flatMap { event in event.updateAddress().map{ event }.catchErrorJustReturn(event) }
|
||||||
.flatMap { Api.add(event: $0, to: vehicle.number) }
|
.flatMap { Api.add(event: $0, to: vehicle.number) }
|
||||||
.subscribe(onSuccess: self.save(vehicle:), onError: { print("Error adding event: \($0)") })
|
.subscribe(onSuccess: self.save(vehicle:), onError: { print("Error adding event: \($0)") })
|
||||||
.disposed(by: self.bag)
|
.disposed(by: self.bag)
|
||||||
|
|||||||
@ -28,6 +28,7 @@ enum ReportGeneralSection: Int, CaseIterable, CustomStringConvertible {
|
|||||||
case wheelPosition = 3
|
case wheelPosition = 3
|
||||||
case japanese = 4
|
case japanese = 4
|
||||||
case owners = 5
|
case owners = 5
|
||||||
|
case events = 6
|
||||||
|
|
||||||
var description: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
@ -37,6 +38,7 @@ enum ReportGeneralSection: Int, CaseIterable, CustomStringConvertible {
|
|||||||
case .wheelPosition: return "Steering wheel position"
|
case .wheelPosition: return "Steering wheel position"
|
||||||
case .japanese: return "Japanese"
|
case .japanese: return "Japanese"
|
||||||
case .owners: return "Owners (from PTS)"
|
case .owners: return "Owners (from PTS)"
|
||||||
|
case .events: return "Events"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,6 +174,8 @@ class ReportController: UIViewController, UICollectionViewDataSource, UICollecti
|
|||||||
case .owners:
|
case .owners:
|
||||||
cell?.configure(param: generalSection.description, value: String(vehicle.ownershipPeriods.count))
|
cell?.configure(param: generalSection.description, value: String(vehicle.ownershipPeriods.count))
|
||||||
break
|
break
|
||||||
|
case .events:
|
||||||
|
cell?.configure(param: generalSection.description, value: String(vehicle.events.count))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cell ?? UICollectionViewCell()
|
return cell ?? UICollectionViewCell()
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import RealmSwift
|
import RealmSwift
|
||||||
|
import RxSwift
|
||||||
|
|
||||||
class VehicleEvent: Object, Codable {
|
class VehicleEvent: Object, Codable {
|
||||||
@objc dynamic var date: TimeInterval = Date().timeIntervalSince1970
|
@objc dynamic var date: TimeInterval = Date().timeIntervalSince1970
|
||||||
@ -20,7 +21,9 @@ class VehicleEvent: Object, Codable {
|
|||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
override class func ignoredProperties() -> [String] {
|
func updateAddress() -> Single<Void> {
|
||||||
return ["address"]
|
return LocationManager
|
||||||
|
.getAddressForLocation(latitude: self.latitude, longitude: self.longitude)
|
||||||
|
.map { self.address = $0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,8 @@ import Foundation
|
|||||||
enum Constants {
|
enum Constants {
|
||||||
static var baseUrl: String {
|
static var baseUrl: String {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
//return "http://192.168.1.67:3000/"
|
return "http://192.168.1.67:3000/"
|
||||||
return "https://vps.aliencat.pro:8443/"
|
//return "https://vps.aliencat.pro:8443/"
|
||||||
#else
|
#else
|
||||||
return "https://vps.aliencat.pro:8443/"
|
return "https://vps.aliencat.pro:8443/"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -19,17 +19,6 @@ class RxLocationManagerDelegateProxy: DelegateProxy<CLLocationManager, CLLocatio
|
|||||||
print("deinit")
|
print("deinit")
|
||||||
}
|
}
|
||||||
|
|
||||||
// func generateAuthObservable() -> Observable<CLAuthorizationStatus> {
|
|
||||||
// self.authSubject = PublishSubject<CLAuthorizationStatus>()
|
|
||||||
// return self.authSubject
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func generateLocationObservable() -> Observable<CLLocation> {
|
|
||||||
// print("generateLocationObservable")
|
|
||||||
// self.locationSubject = PublishSubject<CLLocation>()
|
|
||||||
// return self.locationSubject
|
|
||||||
// }
|
|
||||||
|
|
||||||
// MARK: - DelegateProxyType
|
// MARK: - DelegateProxyType
|
||||||
|
|
||||||
static func registerKnownImplementations() {
|
static func registerKnownImplementations() {
|
||||||
@ -126,4 +115,24 @@ class LocationManager {
|
|||||||
self.manager.stopUpdatingLocation()
|
self.manager.stopUpdatingLocation()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func getAddressForLocation(latitude: Double, longitude: Double) -> Single<String> {
|
||||||
|
return Single.create { observer in
|
||||||
|
let geocoder = CLGeocoder()
|
||||||
|
let location = CLLocation(latitude: latitude, longitude: longitude)
|
||||||
|
geocoder.reverseGeocodeLocation(location) { placemarks, error in
|
||||||
|
if let error = error {
|
||||||
|
observer(.error(error))
|
||||||
|
} else if let placemark = placemarks?.first, let name = placemark.name {
|
||||||
|
observer(.success(name))
|
||||||
|
} else {
|
||||||
|
observer(.error(NSError(domain: "", code: 0, userInfo: [NSLocalizedDescriptionKey: "Reverse geolocation error"])))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Disposables.create {
|
||||||
|
geocoder.cancelGeocode()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user