-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathMBPlacemarkScope.swift
More file actions
69 lines (67 loc) · 2.17 KB
/
MBPlacemarkScope.swift
File metadata and controls
69 lines (67 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
public typealias PlacemarkScope = MBPlacemarkScope
extension PlacemarkScope: CustomStringConvertible {
/**
Initializes a placemark scope bitmask corresponding to the given array of string representations of scopes.
*/
public init?(descriptions: [String]) {
var scope: PlacemarkScope = []
for description in descriptions {
switch description {
case "country":
scope.update(with: .country)
case "region":
scope.update(with: .region)
case "district":
scope.update(with: .district)
case "postcode":
scope.update(with: .postalCode)
case "place":
scope.update(with: .place)
case "locality":
scope.update(with: .locality)
case "neighborhood":
scope.update(with: .neighborhood)
case "address":
scope.update(with: .address)
case "poi.landmark":
scope.update(with: .landmark)
case "poi":
scope.update(with: .pointOfInterest)
default:
return nil
}
}
self.init(rawValue: scope.rawValue)
}
public var description: String {
var descriptions: [String] = []
if contains(.country) {
descriptions.append("country")
}
if contains(.region) {
descriptions.append("region")
}
if contains(.district) {
descriptions.append("district")
}
if contains(.postalCode) {
descriptions.append("postcode")
}
if contains(.place) {
descriptions.append("place")
}
if contains(.locality) {
descriptions.append("locality")
}
if contains(.neighborhood) {
descriptions.append("neighborhood")
}
if contains(.address) {
descriptions.append("address")
}
if contains(.landmark) {
descriptions.append(contains(.pointOfInterest) ? "poi" : "poi.landmark")
}
return descriptions.joined(separator: ",")
}
}