All Projects → raphaelmor → Polyline

raphaelmor / Polyline

Licence: mit
Polyline encoder / decoder in swift

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Polyline

Mapfish Print
A component of MapFish for printing templated cartographic maps. This module is the Java serverside module. For support post to the mailing list: https://groups.google.com/forum/#!forum/mapfish-print-users
Stars: ✭ 159 (-29.02%)
Mutual labels:  maps
Airbnb Android Google Map View
This is a sample Android Application which has Google Map view similar to what AirBnb Android Application. Moving Markers like Uber/Ola. Custom Google Search for places. Recycler view with Animations added.
Stars: ✭ 175 (-21.87%)
Mutual labels:  maps
Openglobus
JavaScript 3d maps and geospatial data visualization engine library.
Stars: ✭ 199 (-11.16%)
Mutual labels:  maps
Interviewbit
Collection of Abhishek Agrawal's gists solutions for problems on https://www.interviewbit.com
Stars: ✭ 166 (-25.89%)
Mutual labels:  maps
Google Maps
Google Maps Web Services API wrapper for .NET
Stars: ✭ 171 (-23.66%)
Mutual labels:  maps
R Gis Tutorial
Spatial data in R: using R as a GIS
Stars: ✭ 191 (-14.73%)
Mutual labels:  maps
Aerialbot
A simple yet highly configurable bot that tweets geotagged aerial imagery of a random location in the world.
Stars: ✭ 157 (-29.91%)
Mutual labels:  maps
Mapbox Plugins Android
Mapbox Android Plugins are a collection of libraries that extend our other SDKs, helping you design powerful mapping features while the plugins handle most of the heavy lifting.
Stars: ✭ 208 (-7.14%)
Mutual labels:  maps
Atlas
OSM in memory
Stars: ✭ 172 (-23.21%)
Mutual labels:  maps
Ember Leaflet
🔥 🍃 Easy and declarative mapping for ember
Stars: ✭ 201 (-10.27%)
Mutual labels:  maps
Azuremapscodesamples
A set of code samples for the Azure Maps web control.
Stars: ✭ 167 (-25.45%)
Mutual labels:  maps
React Native Maps
React Native Mapview component for iOS + Android
Stars: ✭ 12,795 (+5612.05%)
Mutual labels:  maps
React Native Open Maps
🗺 A simple react-native library to perform cross-platform map actions (Google or Apple Maps)
Stars: ✭ 192 (-14.29%)
Mutual labels:  maps
Porymap
Map editor for pokeemerald, pokefirered, and pokeruby
Stars: ✭ 164 (-26.79%)
Mutual labels:  maps
Google Maps Services Js
Node.js client library for Google Maps API Web Services
Stars: ✭ 2,432 (+985.71%)
Mutual labels:  maps
Pulley
A library to imitate the iOS 10 Maps UI.
Stars: ✭ 1,928 (+760.71%)
Mutual labels:  maps
Openrouteservice App
🚙 The open source route planner app with plenty of features.
Stars: ✭ 187 (-16.52%)
Mutual labels:  maps
Cartoframes
CARTO Python package for data scientists
Stars: ✭ 208 (-7.14%)
Mutual labels:  maps
Geoserver
Official GeoServer repository
Stars: ✭ 2,573 (+1048.66%)
Mutual labels:  maps
Terrarium
Some code for generating topographic contour maps.
Stars: ✭ 195 (-12.95%)
Mutual labels:  maps

Build Status CocoaPods Swift 5 Licence

Polyline encoder / decoder in Swift

  1. Features
  2. Requirements
  3. Integration
  4. Usage
  5. Notes
  6. Contributors
  7. License

Features

  • Encode a CLLocationCoordinate2D array to a polyline
  • Decode a polyline to an array of CLLocationCoordinate2D
  • Encode a CLLocation array to a polyline
  • Decode a polyline to an array of CLLocation
  • Encode/Decode associated levels (optional)
  • 100% Unit Test Coverage
  • Complete Documentation
  • Continuous integration with Travis CI
  • CocoaPod available
  • Convert to MKPolyline

Planned for future releases

  • Convert to GMSPolyline
  • Example project
  • Filter locations available at a specific level

Planned when support is available :

Requirements

  • Xcode 11+
  • iOS 10.0+ / Mac OS X 10.12+ / tvOS 10.0+ / watchOS 3.0+ / Linux
  • Swift 5.0

Integration

To use this library in your project you can use CocoaPods, Carthage, Swift Package Manager, and/or integrate it manually :

CocoaPods

You can integrate Polyline in your Podfile like this:

pod 'Polyline', '~> 5.0'

Carthage

You can integrate Polyline in your Cartfile like this:

github "raphaelmor/Polyline" ~> 5.0

Swift Package Manager

You can integrate Polyline using the Swift Package Manager, add the following package to the dependencies in your Package.swift file:

.package(url: "https://github.com/raphaelmor/Polyline.git", from: "5.0.2")

Manual

  • Drag Polyline.swift inside your project tree.
  • For Workspaces you may include the whole Polyline.xcodeproj

Usage

Polyline Encoding

Using [CLLocationCoordinate2D] (recommended) :

let coordinates = [CLLocationCoordinate2D(latitude: 40.2349727, longitude: -3.7707443),
CLLocationCoordinate2D(latitude: 44.3377999, longitude: 1.2112933)]

let polyline = Polyline(coordinates: coordinates)
let encodedPolyline: String = polyline.encodedPolyline

// Or for a functional approach :
let encodedPolyline: String = encodeCoordinates(coordinates)

Using [CLLocation] :

let locations = [CLLocation(latitude: 40.2349727, longitude: -3.7707443),
CLLocation(latitude: 44.3377999, longitude: 1.2112933)]

let polyline = Polyline(locations: locations)
let encodedPolyline: String = polyline.encodedPolyline

// Or for a functional approach :
let encodedPolyline: String = encodeLocations(locations)

You can encode levels too :

let levels: [UInt32] = [0,1,2,255]

let polyline = Polyline(coordinates: coordinates, levels: levels)
let encodedLevels: String? = polyline.encodedLevels

// Or for a functional approach :
let encodedLevels: String = encodedLevels(levels)

Polyline Decoding

You can decode to [CLLocationCoordinate2D] (recommended) :

let polyline = Polyline(encodedPolyline: "qkqtFbn_Vui`Xu`l]")
let decodedCoordinates: [CLLocationCoordinate2D]? = polyline.coordinates

// Or for a functional approach :
let coordinates: [CLLocationCoordinate2D]? = decodePolyline("qkqtFbn_Vui`Xu`l]")

You can also decode to [CLLocation] :

let polyline = Polyline(encodedPolyline: "qkqtFbn_Vui`Xu`l]")
let decodedLocations: [CLLocation]? = polyline.locations

// Or for a functional approach :
let locations: [CLLocation]? = decodePolyline("qkqtFbn_Vui`Xu`l]")

You can decode levels too :

let polyline = Polyline(encodedPolyline: "qkqtFbn_Vui`Xu`l]", encodedLevels: "BA")
let decodedLevels: [UInt32]? = polyline.levels

// Or for a functional approach :
let levels: [UInt32]? = decodeLevels("BA")

Polyline Precision

Default precision is 1e5 : 0.12345 (5 digit precision used by Google), but you can specify your own precision in all API methods (and functions).

// OSRM uses a 6 digit precision
let polyline = Polyline(encodedPolyline: "ak{hRak{hR", precision: 1e6)

Notes

This library tries to have consistent results with polylines generated by the Google Maps iOS SDK. The online tool for encoding polylines has some minor inconsistencies regarding rounding (for example, 0.000015 is rounded to 0.00002 for latitudes, but 0.00001 for longitudes).

This codes tries to adhere to the GitHub Swift Style Guide

Contributors

License

Polyline is released under an MIT license. See LICENSE.txt for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].