0001 // 0002 // PeliasPlaceConfig.swift 0003 // pelias-ios-sdk 0004 // 0005 // Created by Matt Smollinger on 2/16/16. 0006 // Copyright © 2016 Mapzen. All rights reserved. 0007 // 0008 0009 import Foundation 0010 0011 public struct PeliasPlaceConfig: PlaceAPIConfigData { 0012 0013 var urlEndpoint = NSURL.init(string: "/v1/place", relativeToURL: PeliasSearchManager.sharedInstance.baseUrl)! 0014 var queryItems = [String:NSURLQueryItem]() 0015 var completionHandler
PeliasSearchManager.swift:42 public func placeQuery(config: PeliasPlaceConfig) -> PeliasOperation {: (PeliasResponse) -> Void 0016 0017 var apiKey
PeliasPlaceConfig.swift:33 self.completionHandler = completionHandler: String? { 0018 didSet { 0019 if let key = apiKey where apiKey?.isEmpty == false { 0020 appendQueryItem("api_key", value: key) 0021 } 0022 } 0023 } 0024 0025 var places
PeliasPlaceConfig.swift:19 if let key = apiKey where apiKey?.isEmpty == false {PeliasPlaceConfig.swift:19 if let key = apiKey where apiKey?.isEmpty == false {PeliasPlaceConfig.swift:34 apiKey = PeliasSearchManager.sharedInstance.apiKeyPeliasPlaceConfig.swift:38 appendQueryItem("api_key", value: apiKey): [PlaceAPIQueryItem] { 0026 didSet { 0027 buildPlaceQueryItem() 0028 } 0029 } 0030 0031 init(places: [PlaceAPIQueryItem], completionHandler: (PeliasResponse) -> Void){ 0032 self.places = places 0033 self.completionHandler = completionHandler 0034 apiKey = PeliasSearchManager.sharedInstance.apiKey 0035 0036 defer { 0037 //didSet will not fire because self is not setup so we have to do this manually 0038 appendQueryItem("api_key", value: apiKey) 0039 buildPlaceQueryItem() 0040 } 0041 } 0042 0043 mutating func buildPlaceQueryItem
PeliasPlaceConfig.swift:32 self.places = placesPeliasPlaceConfig.swift:44 if places.count <= 0 {PeliasPlaceConfig.swift:48 for place in places {() { 0044 if places.count <= 0 { 0045 return 0046 } 0047 var queryString = "" 0048 for place in places { 0049 let addition = "\(place.dataSource.rawValue):\(place.layer.rawValue):\(place.placeId)" 0050 if queryString.isEmpty { 0051 queryString = addition 0052 } else { 0053 queryString += "&\(addition)" 0054 } 0055 } 0056 0057 appendQueryItem("ids", value: queryString) 0058 } 0059 } 0060 0061 public struct PeliasPlaceQueryItem : PlaceAPIQueryItem { 0062 var placeId
PeliasPlaceConfig.swift:27 buildPlaceQueryItem()PeliasPlaceConfig.swift:39 buildPlaceQueryItem(): String 0063 var dataSource
PeliasPlaceConfig.swift:67 self.placeId = placeId: SearchSource 0064 var layer
PeliasPlaceConfig.swift:68 self.dataSource = dataSource: LayerFilter 0065 0066 init(placeId: String, dataSource: SearchSource, layer: LayerFilter) { 0067 self.placeId = placeId 0068 self.dataSource = dataSource 0069 self.layer = layer 0070 } 0071 } 0072
PeliasPlaceConfig.swift:69 self.layer = layer