Skip to content

Commit

Permalink
Retro compatibility on addRegion with identifier, get error if the co…
Browse files Browse the repository at this point in the history
…nfig file don't exist
  • Loading branch information
Llumbroso committed Mar 18, 2022
1 parent 1d55ec9 commit 83e8507
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
19 changes: 4 additions & 15 deletions WoosmapGeofencing/Sources/WoosmapGeofencing/Monitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,31 +254,20 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
}
}

public func addRegion(identifier: String, center: CLLocationCoordinate2D, radius: Int, type: String) -> (isCreate: Bool, state: String){
public func addRegion(identifier: String, center: CLLocationCoordinate2D, radius: Int, type: String) -> (isCreate: Bool, identifier: String){
if(type == "isochrone"){
let regionIsCreated = addRegionIsochrone(identifier: identifier, center: center, radius: radius)
var state = ""
if(regionIsCreated) {
state = "The region is created"
} else {
state = "Identifier already exist"
}
return (regionIsCreated, state)
return (regionIsCreated, identifier)
} else if(type == "circle"){
let regionIsCreated = addRegion(identifier: identifier, center: center, radius: Double(radius))
var state = ""
if(regionIsCreated) {
state = "The region is created"
} else {
state = "You can't create more than 20 regions"
}
return (regionIsCreated, state)
return (regionIsCreated, identifier)
}
return (false, "the type is incorrect")
}

public func addRegionIsochrone(identifier: String, center: CLLocationCoordinate2D, radius: Int) -> Bool {
if (RegionIsochrones.getRegionFromId(id: identifier) != nil) {
print("Identifier already exist")
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,12 @@ import RealmSwift

public func startTracking(configurationProfile: ConfigurationProfile){
let bundle = Bundle(for: Self.self)
let url = bundle.url(forResource: configurationProfile.rawValue, withExtension: ".json")
guard let url = bundle.url(forResource: configurationProfile.rawValue, withExtension: ".json") else {
print(["Error: \(configurationProfile.rawValue) profil loading"])
return
}
do {
let jsonData = try Data(contentsOf: url!)
let jsonData = try Data(contentsOf: url)
let configJSON = try? JSONDecoder().decode(ConfigModel.self, from: jsonData)
setTrackingEnable(enable: configJSON?.trackingEnable ?? false)
setModeHighfrequencyLocation(enable: configJSON?.modeHighFrequencyLocation ?? false)
Expand Down

0 comments on commit 83e8507

Please sign in to comment.