Skip to content

Commit

Permalink
Merge pull request #78 from Woosmap/dev/IdentifierRegion
Browse files Browse the repository at this point in the history
add attribut origin, identifier name cleared on Region Database object,
  • Loading branch information
Llumbroso authored Mar 31, 2022
2 parents d5c7b34 + 94bf00b commit 9f92b84
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 39 deletions.
60 changes: 29 additions & 31 deletions WoosmapGeofencing.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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: "<id>")[1]
origin = "POI"
} else if (POIregion.identifier.contains(LocationService.RegionType.custom.rawValue)) {
identifier = POIregion.identifier.components(separatedBy: "<id>")[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()
Expand Down Expand Up @@ -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()
Expand All @@ -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: "<id>")[1]
}
let predicate = NSPredicate(format: "identifier == %@", identifier)
let fetchedResults = realm.objects(Region.self).filter(predicate)
if let aRegion = fetchedResults.last {
return aRegion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"distanceAPIEnable": false,

"distance": {
"distanceProvider": "woosmapTraffic",
"distanceProvider": "woosmapDistance",
"distanceMode": "driving",
"distanceRouting": "fastest",
"distanceUnits": "metric",
Expand Down
5 changes: 2 additions & 3 deletions WoosmapGeofencing/Sources/WoosmapGeofencing/Monitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<id>")[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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" */ = {
Expand Down

0 comments on commit 9f92b84

Please sign in to comment.