Skip to content

Commit

Permalink
Depend on Polyline.framework
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Feb 23, 2017
1 parent 0e3e61f commit 6ffd695
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 38 deletions.
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "raphaelmor/Polyline" "f86f34dac9aae7e027fd9f62c2e01dd77f1ee312"
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github "AliSoftware/OHHTTPStubs" "57feceaabf333e72b2c637dfba6c13a7a5c49619"
github "raphaelmor/Polyline" "f86f34dac9aae7e027fd9f62c2e01dd77f1ee312"
2 changes: 2 additions & 0 deletions MapboxStatic.swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.module_name = "MapboxStatic"

s.dependency "Polyline", "~> 4.0"

end
48 changes: 48 additions & 0 deletions MapboxStatic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
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 */; };
Expand Down Expand Up @@ -82,6 +86,10 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
DA0584D51E5EE5E6006F138F /* Polyline.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Polyline.framework; path = Carthage/Build/iOS/Polyline.framework; sourceTree = "<group>"; };
DA0584D71E5EE601006F138F /* Polyline.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Polyline.framework; path = Carthage/Build/Mac/Polyline.framework; sourceTree = "<group>"; };
DA0584D91E5EE60A006F138F /* Polyline.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Polyline.framework; path = Carthage/Build/tvOS/Polyline.framework; sourceTree = "<group>"; };
DA0584DB1E5EE60F006F138F /* Polyline.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Polyline.framework; path = Carthage/Build/watchOS/Polyline.framework; sourceTree = "<group>"; };
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 = "<group>"; };
DA20FB9F1CE3DEBB00B07762 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -120,13 +128,15 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DA0584D61E5EE5E6006F138F /* Polyline.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DA20FBB51CE4757E00B07762 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DA0584D81E5EE601006F138F /* Polyline.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -142,6 +152,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DA0584DA1E5EE60A006F138F /* Polyline.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -157,6 +168,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DA0584DC1E5EE60F006F138F /* Polyline.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -202,6 +214,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 */,
Expand Down Expand Up @@ -809,6 +825,10 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
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";
Expand All @@ -831,6 +851,10 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
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";
Expand All @@ -854,6 +878,10 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
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";
Expand All @@ -879,6 +907,10 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
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";
Expand Down Expand Up @@ -943,6 +975,10 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
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";
Expand All @@ -968,6 +1004,10 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
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";
Expand Down Expand Up @@ -1030,6 +1070,10 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
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";
Expand All @@ -1056,6 +1100,10 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
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";
Expand Down
40 changes: 2 additions & 38 deletions MapboxStatic/Overlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#else
import UIKit
#endif
import Polyline

let allowedCharacterSet: CharacterSet = {
var characterSet = CharacterSet.urlPathAllowed
Expand Down Expand Up @@ -393,45 +394,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)!
return "path-\(strokeWidth)+\(strokeColor.toHexString())-\(strokeOpacity)+\(fillColor.toHexString())-\(fillOpacity)(\(encodedPolyline))"
}
}

0 comments on commit 6ffd695

Please sign in to comment.