diff --git a/Cartfile b/Cartfile new file mode 100644 index 0000000..5a0026a --- /dev/null +++ b/Cartfile @@ -0,0 +1,2 @@ +github "raphaelmor/Polyline" ~> 4.2 + diff --git a/Cartfile.resolved b/Cartfile.resolved index bf0e19e..5c0ad66 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1,3 @@ -github "AliSoftware/OHHTTPStubs" "6.0.0" +github "AliSoftware/OHHTTPStubs" "6.1.0" +github "raphaelmor/Polyline" "v4.2.0" + diff --git a/MapboxStatic.swift.podspec b/MapboxStatic.swift.podspec index c65f682..ab0e607 100644 --- a/MapboxStatic.swift.podspec +++ b/MapboxStatic.swift.podspec @@ -42,4 +42,6 @@ Pod::Spec.new do |s| s.requires_arc = true s.module_name = "MapboxStatic" + s.dependency "Polyline", "~> 4.2" + end diff --git a/MapboxStatic.xcodeproj/project.pbxproj b/MapboxStatic.xcodeproj/project.pbxproj index d06bd6f..343970d 100644 --- a/MapboxStatic.xcodeproj/project.pbxproj +++ b/MapboxStatic.xcodeproj/project.pbxproj @@ -91,8 +91,11 @@ DA1BA2861E6D39AE007F9FAC /* path.png in Resources */ = {isa = PBXBuildFile; fileRef = DA1BA2851E6D39AE007F9FAC /* path.png */; }; DA1BA2871E6D39AE007F9FAC /* path.png in Resources */ = {isa = PBXBuildFile; fileRef = DA1BA2851E6D39AE007F9FAC /* path.png */; }; DA1BA2881E6D39AE007F9FAC /* path.png in Resources */ = {isa = PBXBuildFile; fileRef = DA1BA2851E6D39AE007F9FAC /* path.png */; }; + DA0584D61E5EE5E6006F138F /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA0584D51E5EE5E6006F138F /* Polyline.framework */; }; + DA0584D81E5EE601006F138F /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA0584D71E5EE601006F138F /* Polyline.framework */; }; + DA0584DA1E5EE60A006F138F /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA0584D91E5EE60A006F138F /* Polyline.framework */; }; + DA0584DC1E5EE60F006F138F /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA0584DB1E5EE60F006F138F /* Polyline.framework */; }; DA20FB9E1CE3DEBB00B07762 /* MapboxStatic.h in Headers */ = {isa = PBXBuildFile; fileRef = DA20FB9D1CE3DEBB00B07762 /* MapboxStatic.h */; settings = {ATTRIBUTES = (Public, ); }; }; - DA20FBA21CE3DEBB00B07762 /* MapboxStatic.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA20FB9B1CE3DEBB00B07762 /* MapboxStatic.framework */; }; DA20FBA81CE3DF6900B07762 /* Snapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAD19871BD9B3970057AC9F /* Snapshot.swift */; }; DA20FBAA1CE401E800B07762 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20FBA91CE401E800B07762 /* Color.swift */; }; DA20FBAC1CE4026B00B07762 /* Overlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20FBAB1CE4026B00B07762 /* Overlay.swift */; }; @@ -126,6 +129,13 @@ DAE8CCC41E6E992E009B5CB0 /* zoom-gl.png in Resources */ = {isa = PBXBuildFile; fileRef = DAE8CCC31E6E992E009B5CB0 /* zoom-gl.png */; }; DAE8CCC51E6E992E009B5CB0 /* zoom-gl.png in Resources */ = {isa = PBXBuildFile; fileRef = DAE8CCC31E6E992E009B5CB0 /* zoom-gl.png */; }; DAE8CCC61E6E992E009B5CB0 /* zoom-gl.png in Resources */ = {isa = PBXBuildFile; fileRef = DAE8CCC31E6E992E009B5CB0 /* zoom-gl.png */; }; + DAA4014D1E7652EE00998ACE /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA0584D51E5EE5E6006F138F /* Polyline.framework */; }; + DAA4014E1E7652F600998ACE /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA0584D71E5EE601006F138F /* Polyline.framework */; }; + DAA4014F1E7652FB00998ACE /* Polyline.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA0584D91E5EE60A006F138F /* Polyline.framework */; }; + DAA401531E7656B900998ACE /* MapboxStatic.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA20FB9B1CE3DEBB00B07762 /* MapboxStatic.framework */; }; + DAA401541E7656B900998ACE /* MapboxStatic.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA20FB9B1CE3DEBB00B07762 /* MapboxStatic.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + DAA401561E7656F000998ACE /* MapboxStatic.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA20FB9B1CE3DEBB00B07762 /* MapboxStatic.framework */; }; + DAA401571E7656F000998ACE /* MapboxStatic.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA20FB9B1CE3DEBB00B07762 /* MapboxStatic.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; DAF158881D03E7AC00829B35 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DAF158871D03E7AC00829B35 /* Launch Screen.storyboard */; }; DAF158891D03E7AC00829B35 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DAF158871D03E7AC00829B35 /* Launch Screen.storyboard */; }; DAF15A431CE8FBBC0040E86C /* MapboxStatic.h in Headers */ = {isa = PBXBuildFile; fileRef = DA20FB9D1CE3DEBB00B07762 /* MapboxStatic.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -135,7 +145,6 @@ DAF15A4F1CE90A6C0040E86C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DAF15A4E1CE90A6C0040E86C /* main.m */; }; DAF15A521CE90A6C0040E86C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DAF15A511CE90A6C0040E86C /* AppDelegate.m */; }; DAF15A551CE90A6C0040E86C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DAF15A541CE90A6C0040E86C /* ViewController.m */; }; - DAF15A631CE90CE70040E86C /* MapboxStatic.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA20FB9B1CE3DEBB00B07762 /* MapboxStatic.framework */; }; DD0C88181BE1A9E100606E9F /* polyline.geojson in Resources */ = {isa = PBXBuildFile; fileRef = DD0C88161BE1A9D400606E9F /* polyline.geojson */; }; DD685BA91BDB14C1002E2BB2 /* MapboxStaticTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAD19831BD9B2F80057AC9F /* MapboxStaticTests.swift */; }; DDAD19711BD9B1A50057AC9F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAD196E1BD9B1A50057AC9F /* AppDelegate.swift */; }; @@ -180,6 +189,31 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + DAA401551E7656B900998ACE /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + DAA401541E7656B900998ACE /* MapboxStatic.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + DAA401581E7656F000998ACE /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + DAA401571E7656F000998ACE /* MapboxStatic.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ DA031C611E6F4824007CA06A /* rotate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rotate.png; sourceTree = ""; }; DA031C651E6F487E007CA06A /* tilt.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tilt.png; sourceTree = ""; }; @@ -208,6 +242,10 @@ DA1BA27D1E6D2DE3007F9FAC /* rocket.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rocket.png; sourceTree = ""; }; DA1BA2811E6D3386007F9FAC /* geojson.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = geojson.png; sourceTree = ""; }; DA1BA2851E6D39AE007F9FAC /* path.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = path.png; sourceTree = ""; }; + DA0584D51E5EE5E6006F138F /* Polyline.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Polyline.framework; path = Carthage/Build/iOS/Polyline.framework; sourceTree = ""; }; + DA0584D71E5EE601006F138F /* Polyline.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Polyline.framework; path = Carthage/Build/Mac/Polyline.framework; sourceTree = ""; }; + DA0584D91E5EE60A006F138F /* Polyline.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Polyline.framework; path = Carthage/Build/tvOS/Polyline.framework; sourceTree = ""; }; + DA0584DB1E5EE60F006F138F /* Polyline.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Polyline.framework; path = Carthage/Build/watchOS/Polyline.framework; sourceTree = ""; }; DA20FB9B1CE3DEBB00B07762 /* MapboxStatic.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MapboxStatic.framework; sourceTree = BUILT_PRODUCTS_DIR; }; DA20FB9D1CE3DEBB00B07762 /* MapboxStatic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MapboxStatic.h; sourceTree = ""; }; DA20FB9F1CE3DEBB00B07762 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -251,6 +289,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DA0584D61E5EE5E6006F138F /* Polyline.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -258,6 +297,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DA0584D81E5EE601006F138F /* Polyline.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -266,6 +306,7 @@ buildActionMask = 2147483647; files = ( DA9CC68D1E5C551000A14964 /* OHHTTPStubs.framework in Frameworks */, + DAA4014E1E7652F600998ACE /* Polyline.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -273,6 +314,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DA0584DA1E5EE60A006F138F /* Polyline.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -281,6 +323,7 @@ buildActionMask = 2147483647; files = ( DA9CC68F1E5C551500A14964 /* OHHTTPStubs.framework in Frameworks */, + DAA4014F1E7652FB00998ACE /* Polyline.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -288,6 +331,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DA0584DC1E5EE60F006F138F /* Polyline.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -295,7 +339,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - DAF15A631CE90CE70040E86C /* MapboxStatic.framework in Frameworks */, + DAA401561E7656F000998ACE /* MapboxStatic.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -303,7 +347,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - DA20FBA21CE3DEBB00B07762 /* MapboxStatic.framework in Frameworks */, + DAA401531E7656B900998ACE /* MapboxStatic.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -312,6 +356,7 @@ buildActionMask = 2147483647; files = ( DA9CC68B1E5C550000A14964 /* OHHTTPStubs.framework in Frameworks */, + DAA4014D1E7652EE00998ACE /* Polyline.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -336,6 +381,10 @@ DA9CC6891E5C550000A14964 /* Frameworks */ = { isa = PBXGroup; children = ( + DA0584DB1E5EE60F006F138F /* Polyline.framework */, + DA0584D91E5EE60A006F138F /* Polyline.framework */, + DA0584D71E5EE601006F138F /* Polyline.framework */, + DA0584D51E5EE5E6006F138F /* Polyline.framework */, DA9CC68E1E5C551500A14964 /* OHHTTPStubs.framework */, DA9CC68C1E5C551000A14964 /* OHHTTPStubs.framework */, DA9CC68A1E5C550000A14964 /* OHHTTPStubs.framework */, @@ -607,6 +656,7 @@ DAF15A471CE90A6C0040E86C /* Sources */, DAF15A481CE90A6C0040E86C /* Frameworks */, DAF15A491CE90A6C0040E86C /* Resources */, + DAA401581E7656F000998ACE /* Embed Frameworks */, ); buildRules = ( ); @@ -625,6 +675,7 @@ DDAD19551BD9B1780057AC9F /* Sources */, DDAD19561BD9B1780057AC9F /* Frameworks */, DDAD19571BD9B1780057AC9F /* Resources */, + DAA401551E7656B900998ACE /* Embed Frameworks */, ); buildRules = ( ); @@ -885,6 +936,7 @@ ); inputPaths = ( "$(SRCROOT)/Carthage/Build/iOS/OHHTTPStubs.framework", + "$(SRCROOT)/Carthage/Build/iOS/Polyline.framework", ); name = "Copy Frameworks"; outputPaths = ( @@ -900,6 +952,7 @@ ); inputPaths = ( "$(SRCROOT)/Carthage/Build/Mac/OHHTTPStubs.framework", + "$(SRCROOT)/Carthage/Build/Mac/Polyline.framework", ); name = "Copy Frameworks"; outputPaths = ( @@ -915,6 +968,7 @@ ); inputPaths = ( "$(SRCROOT)/Carthage/Build/tvOS/OHHTTPStubs.framework", + "$(SRCROOT)/Carthage/Build/tvOS/Polyline.framework", ); name = "Copy Frameworks"; outputPaths = ( @@ -1071,6 +1125,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 7; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); INFOPLIST_FILE = MapboxStatic/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1093,6 +1151,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 7; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); INFOPLIST_FILE = MapboxStatic/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1116,6 +1178,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 7; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/Mac", + ); FRAMEWORK_VERSION = A; INFOPLIST_FILE = MapboxStatic/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -1141,6 +1207,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 7; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/Mac", + ); FRAMEWORK_VERSION = A; INFOPLIST_FILE = MapboxStatic/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -1203,6 +1273,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 7; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/tvOS", + ); INFOPLIST_FILE = "$(SRCROOT)/MapboxStatic/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1228,6 +1302,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 7; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/tvOS", + ); INFOPLIST_FILE = "$(SRCROOT)/MapboxStatic/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1290,6 +1368,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 7; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/watchOS", + ); INFOPLIST_FILE = MapboxStatic/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1316,6 +1398,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 7; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/watchOS", + ); INFOPLIST_FILE = MapboxStatic/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1452,6 +1538,7 @@ DDAD196C1BD9B1780057AC9F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CURRENT_PROJECT_VERSION = 7; INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1465,6 +1552,7 @@ DDAD196D1BD9B1780057AC9F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CURRENT_PROJECT_VERSION = 7; INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/MapboxStatic/Overlay.swift b/MapboxStatic/Overlay.swift index fcbde9b..b53b60d 100644 --- a/MapboxStatic/Overlay.swift +++ b/MapboxStatic/Overlay.swift @@ -3,6 +3,7 @@ #else import UIKit #endif +import Polyline let allowedCharacterSet: CharacterSet = { var characterSet = CharacterSet.urlPathAllowed @@ -384,45 +385,8 @@ open class Path: NSObject, Overlay { } } - // based on https://github.com/mapbox/polyline - fileprivate func polylineEncode(_ coordinates: [CLLocationCoordinate2D]) -> String { - - func encodeCoordinate(_ coordinate: CLLocationDegrees) -> String { - - var c = Int(round(coordinate * 1e5)) - - c = c << 1 - - if c < 0 { - c = ~c - } - - var output = "" - - while c >= 0x20 { - output += String(describing: UnicodeScalar((0x20 | (c & 0x1f)) + 63)!) - c = c >> 5 - } - - output += String(describing: UnicodeScalar(c + 63)!) - - return output - } - - var output = encodeCoordinate(coordinates[0].latitude) + encodeCoordinate(coordinates[0].longitude) - - for i in 1 ..< coordinates.count { - let a = coordinates[i] - let b = coordinates[i - 1] - output += encodeCoordinate(a.latitude - b.latitude) - output += encodeCoordinate(a.longitude - b.longitude) - } - - return output - } - open override var description: String { - let encodedPolyline = polylineEncode(coordinates).addingPercentEncoding(withAllowedCharacters: allowedCharacterSet)! + let encodedPolyline = encodeCoordinates(coordinates).addingPercentEncoding(withAllowedCharacters: allowedCharacterSet)! var description = "path-\(strokeWidth)+\(strokeColor.toHexString())-\(strokeColor.alphaComponent)" if fillColor.alphaComponent > 0 { description += "+\(fillColor.toHexString())-\(fillColor.alphaComponent)" diff --git a/MapboxStaticTests/ClassicOverlayTests.swift b/MapboxStaticTests/ClassicOverlayTests.swift index 8354b93..04d7bed 100644 --- a/MapboxStaticTests/ClassicOverlayTests.swift +++ b/MapboxStaticTests/ClassicOverlayTests.swift @@ -29,8 +29,14 @@ class ClassicOverlayTests: XCTestCase { options.overlays = [markerOverlay] options.scale = 1 + let hexColor: String + #if os(macOS) + hexColor = "865226" + #else + hexColor = "996633" + #endif stub(condition: isHost("api.mapbox.com") - && isPath("/v4/mapbox.streets/pin-m-cafe+996633(-122.681944,45.52)/auto/200x200.png") + && isPath("/v4/mapbox.streets/pin-m-cafe+\(hexColor)(-122.681944,45.52)/auto/200x200.png") && containsQueryParams(["access_token": BogusToken])) { request in let path = Bundle(for: type(of: self)).path(forResource: "marker", ofType: "png")! return fixture(filePath: path, headers: ["Content-Type": "image/png"]) @@ -96,7 +102,7 @@ class ClassicOverlayTests: XCTestCase { options.overlays = [geoJSONOverlay] options.scale = 1 - let geoJSONString = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"stroke-width\":3,\"stroke-opacity\":1,\"stroke\":\"#00f\"},\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[-122.6978445053101,45.51863175803531],[-122.6909136772156,45.52165369248977],[-122.68630027771,45.51891742047702],[-122.6850986480713,45.51631633525551],[-122.6823306083679,45.51950377568216]]}}]}" + let geoJSONString = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"stroke-width\":3,\"stroke-opacity\":1,\"stroke\":\"#00f\"},\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[-122.69784450531006,45.518631758035312],[-122.69091367721559,45.521653692489771],[-122.68630027770996,45.518917420477024],[-122.68509864807127,45.51631633525551],[-122.68233060836793,45.519503775682161]]}}]}" stub(condition: isHost("api.mapbox.com") && isPath("/v4/mapbox.streets/geojson(\(geoJSONString))/auto/200x200.png") @@ -140,10 +146,15 @@ class ClassicOverlayTests: XCTestCase { options.overlays = [path] options.scale = 1 - let encodedPolyline = "upztG`jxkVn@al@bo@nFWzuAaTcAyZen@" - + let hexColor: String + #if os(macOS) + hexColor = "fb0006" + #else + hexColor = "ff0000" + #endif + let encodedPolyline = "upztG`jxkVn@al@bo@pFWzuAaTcAyZgn@" stub(condition: isHost("api.mapbox.com") - && isPath("/v4/mapbox.streets/path-2+000000-0.75+ff0000-0.25(\(encodedPolyline))/auto/200x200.png") + && isPath("/v4/mapbox.streets/path-2+000000-0.75+\(hexColor)-0.25(\(encodedPolyline))/auto/200x200.png") && containsQueryParams(["access_token": BogusToken])) { request in let path = Bundle(for: type(of: self)).path(forResource: "path", ofType: "png")! return fixture(filePath: path, headers: ["Content-Type": "image/png"]) diff --git a/MapboxStaticTests/ClassicSnapshotTests.swift b/MapboxStaticTests/ClassicSnapshotTests.swift index 54c2cd3..6cd79c0 100644 --- a/MapboxStaticTests/ClassicSnapshotTests.swift +++ b/MapboxStaticTests/ClassicSnapshotTests.swift @@ -166,8 +166,14 @@ class ClassicSnapshotTests: XCTestCase { options.color = .brown options.scale = 1 + let hexColor: String + #if os(macOS) + hexColor = "865226" + #else + hexColor = "996633" + #endif stub(condition: isHost("api.mapbox.com") - && isPath("/v4/marker/pin-m-cafe+996633.png") + && isPath("/v4/marker/pin-m-cafe+\(hexColor).png") && containsQueryParams(["access_token": BogusToken])) { request in let path = Bundle(for: type(of: self)).path(forResource: "cafe", ofType: "png")! return fixture(filePath: path, headers: ["Content-Type": "image/png"])