From 80f4c64613361c165c1e3bdd45e3af1d3a175dae Mon Sep 17 00:00:00 2001 From: llumbroso Date: Wed, 30 Mar 2022 14:57:03 +0200 Subject: [PATCH 1/3] add attribut origin, identifier name cleared on Region Database object, --- .../xcshareddata/swiftpm/Package.resolved | 60 +++++++++---------- .../Business Logic/Region.swift | 20 ++++++- .../WoosmapGeofencing/WoosmapGeofencing.swift | 2 +- .../project.pbxproj | 2 +- 4 files changed, 49 insertions(+), 35 deletions(-) diff --git a/WoosmapGeofencing.xcworkspace/xcshareddata/swiftpm/Package.resolved b/WoosmapGeofencing.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6c89da8..5e2ac43 100644 --- a/WoosmapGeofencing.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/WoosmapGeofencing.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,34 +1,32 @@ { - "object": { - "pins": [ - { - "package": "Realm", - "repositoryURL": "https://github.com/realm/realm-cocoa", - "state": { - "branch": null, - "revision": "9dff9f2862240d521ad6ad599541269177ddb993", - "version": "10.22.0" - } - }, - { - "package": "RealmDatabase", - "repositoryURL": "https://github.com/realm/realm-core", - "state": { - "branch": null, - "revision": "6b81f1a7a2d421f9e0b9e7f04e76bcf736a54409", - "version": "11.9.0" - } - }, - { - "package": "Surge", - "repositoryURL": "https://github.com/Jounce/Surge.git", - "state": { - "branch": null, - "revision": "6e4a47e63da8801afe6188cf039e9f04eb577721", - "version": "2.3.2" - } + "pins" : [ + { + "identity" : "realm-cocoa", + "kind" : "remoteSourceControl", + "location" : "https://github.com/realm/realm-cocoa", + "state" : { + "revision" : "628cf20632d65d3a3e90ae8aaf52bce596d7ad8f", + "version" : "10.24.2" } - ] - }, - "version": 1 + }, + { + "identity" : "realm-core", + "kind" : "remoteSourceControl", + "location" : "https://github.com/realm/realm-core", + "state" : { + "revision" : "dcd3788f75bafb0cc397d145e1651aab3ad4bf0e", + "version" : "11.12.0" + } + }, + { + "identity" : "surge", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Jounce/Surge.git", + "state" : { + "revision" : "6e4a47e63da8801afe6188cf039e9f04eb577721", + "version" : "2.3.2" + } + } + ], + "version" : 2 } diff --git a/WoosmapGeofencing/Sources/WoosmapGeofencing/Business Logic/Region.swift b/WoosmapGeofencing/Sources/WoosmapGeofencing/Business Logic/Region.swift index e676d19..7e41d5e 100644 --- a/WoosmapGeofencing/Sources/WoosmapGeofencing/Business Logic/Region.swift +++ b/WoosmapGeofencing/Sources/WoosmapGeofencing/Business Logic/Region.swift @@ -21,6 +21,7 @@ public class Region: Object { @objc public dynamic var duration = 0; @objc public dynamic var durationText = ""; @objc public dynamic var type = "circle"; + @objc public dynamic var origin = ""; convenience init(latitude: Double, longitude: Double, radius: Double, dateCaptured: Date, identifier: String, didEnter: Bool, fromPositionDetection: Bool) { self.init() @@ -41,7 +42,17 @@ public class Regions { let latRegion = (POIregion as! CLCircularRegion).center.latitude let lngRegion = (POIregion as! CLCircularRegion).center.longitude let radius = (POIregion as! CLCircularRegion).radius - let entry = Region(latitude: latRegion, longitude: lngRegion, radius: radius, dateCaptured: Date(), identifier: POIregion.identifier, didEnter: didEnter, fromPositionDetection: fromPositionDetection) + var identifier = POIregion.identifier + var origin = "custom" + if(POIregion.identifier.contains(LocationService.RegionType.poi.rawValue)) { + identifier = POIregion.identifier.components(separatedBy: "")[1] + origin = "POI" + } else if (POIregion.identifier.contains(LocationService.RegionType.custom.rawValue)) { + identifier = POIregion.identifier.components(separatedBy: "")[1] + origin = "custom" + } + let entry = Region(latitude: latRegion, longitude: lngRegion, radius: radius, dateCaptured: Date(), identifier: identifier, didEnter: didEnter, fromPositionDetection: fromPositionDetection) + entry.origin = origin realm.beginWrite() realm.add(entry) try realm.commitWrite() @@ -73,6 +84,7 @@ public class Regions { entry.distance = regionIso.distance entry.distanceText = regionIso.distanceText entry.type = "isochrone" + entry.origin = "custom" realm.beginWrite() realm.add(entry) try realm.commitWrite() @@ -85,7 +97,11 @@ public class Regions { public class func getRegionFromId(id: String) -> Region? { do { let realm = try Realm() - let predicate = NSPredicate(format: "identifier == %@", id) + var identifier = id + if(id.contains(LocationService.RegionType.poi.rawValue) || id.contains(LocationService.RegionType.custom.rawValue)) { + identifier = id.components(separatedBy: "")[1] + } + let predicate = NSPredicate(format: "identifier == %@", identifier) let fetchedResults = realm.objects(Region.self).filter(predicate) if let aRegion = fetchedResults.last { return aRegion diff --git a/WoosmapGeofencing/Sources/WoosmapGeofencing/WoosmapGeofencing.swift b/WoosmapGeofencing/Sources/WoosmapGeofencing/WoosmapGeofencing.swift index 7c2f8eb..9226d26 100644 --- a/WoosmapGeofencing/Sources/WoosmapGeofencing/WoosmapGeofencing.swift +++ b/WoosmapGeofencing/Sources/WoosmapGeofencing/WoosmapGeofencing.swift @@ -28,7 +28,7 @@ import RealmSwift } private func initRealm() { - Realm.Configuration.defaultConfiguration = Realm.Configuration(schemaVersion: 5) + Realm.Configuration.defaultConfiguration = Realm.Configuration(schemaVersion: 6) } public func getLocationService() -> LocationService { diff --git a/WoosmapGeofencing/WoosmapGeofencing.xcodeproj/project.pbxproj b/WoosmapGeofencing/WoosmapGeofencing.xcodeproj/project.pbxproj index f86d2da..fe63144 100644 --- a/WoosmapGeofencing/WoosmapGeofencing.xcodeproj/project.pbxproj +++ b/WoosmapGeofencing/WoosmapGeofencing.xcodeproj/project.pbxproj @@ -608,7 +608,7 @@ repositoryURL = "https://github.com/realm/realm-cocoa"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 10.22.0; + minimumVersion = 10.24.2; }; }; A2920CDD27690C820024FB06 /* XCRemoteSwiftPackageReference "Surge" */ = { From baf92687bb4088f58af7f75570cc6580aa7d65e2 Mon Sep 17 00:00:00 2001 From: llumbroso Date: Wed, 30 Mar 2022 18:38:47 +0200 Subject: [PATCH 2/3] correction Connector data information --- WoosmapGeofencing/Sources/WoosmapGeofencing/Monitor.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/WoosmapGeofencing/Sources/WoosmapGeofencing/Monitor.swift b/WoosmapGeofencing/Sources/WoosmapGeofencing/Monitor.swift index 3f67027..4b33e55 100644 --- a/WoosmapGeofencing/Sources/WoosmapGeofencing/Monitor.swift +++ b/WoosmapGeofencing/Sources/WoosmapGeofencing/Monitor.swift @@ -900,9 +900,8 @@ public class LocationService: NSObject, CLLocationManagerDelegate { propertyDictionary["lng"] = region.longitude propertyDictionary["radius"] = region.radius - if(getRegionType(identifier: region.identifier) == RegionType.poi) { - let idStore = region.identifier.components(separatedBy: "")[1] - guard let poi = POIs.getPOIbyIdStore(idstore: idStore) else { + if(region.origin == "POI") { + guard let poi = POIs.getPOIbyIdStore(idstore: region.identifier) else { return } setDataFromPOI(poi: poi, propertyDictionary: &propertyDictionary) From 94bf00ba88fd90373a94d975127612382f4b2862 Mon Sep 17 00:00:00 2001 From: llumbroso Date: Thu, 31 Mar 2022 09:37:10 +0200 Subject: [PATCH 3/3] update passive profile with Distance --- .../Sources/WoosmapGeofencing/Config/passiveTracking.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WoosmapGeofencing/Sources/WoosmapGeofencing/Config/passiveTracking.json b/WoosmapGeofencing/Sources/WoosmapGeofencing/Config/passiveTracking.json index 7caa3cf..3a6f48a 100644 --- a/WoosmapGeofencing/Sources/WoosmapGeofencing/Config/passiveTracking.json +++ b/WoosmapGeofencing/Sources/WoosmapGeofencing/Config/passiveTracking.json @@ -23,7 +23,7 @@ "distanceAPIEnable": false, "distance": { - "distanceProvider": "woosmapTraffic", + "distanceProvider": "woosmapDistance", "distanceMode": "driving", "distanceRouting": "fastest", "distanceUnits": "metric",