Popularity
1.9
Declining
Activity
2.9
Growing
9
0
0

Programming language: Crystal
License: MIT License
Tags: Compression    
Latest version: v0.2.0

polylines.cr alternatives and similar shards

Based on the "Compression" category.
Alternatively, view polylines.cr alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of polylines.cr or a related project?

Add another 'Compression' Shard

README

Crystal Lang Polylines

Release Build Status Docs

A Crystal implementation of the Google polyline algorithm.

Greatly inspired by the Ruby implementation fast-polylines, it is mostly existing for performance comparison between Ruby C extensions and Crystal!

If you are curious: encoding is roughly the same, decoding is way faster in Crystal. If you are even more curious, make benchmark here and in fast-polylines ๐Ÿ˜‰. With a MacBook pro 1,4 GHz i5, here's the result:

โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” ENCODING โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”

CrystalPolylines 706.82k (  1.41ยตs) (ยฑ 4.42%)  466B/op  fastest

โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”  DECODING โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”

CrystalPolylines   1.43M (699.73ns) (ยฑ 3.21%)  1.62kB/op  fastest

Installation

Add the dependency to your shard.yml:

dependencies:
  polylines:
    github: BuonOmo/polylines.cr

Run shards install

Usage

require "polylines"

Polylines.encode([{lat: 38.5, lng: -120.2}, {lat: 40.7, lng: -120.95}])
Polylines.encode([[38.5, -120.2], [40.7, -120.95]])
Polylines.encode([{38.5, -120.2}, {40.7, -120.95}])
# => "_p~iF~ps|U_ulLnnqC"

Polylines.decode("_p~iF~ps|U_ulLnnqC")
# => [{lat: 38.5, lng: -120.2}, {lat: 40.7, lng: -120.95}]

Polylines.encode([{lat: 12.1232493, lng: 2.9481493}, {lat: 13.8474392, lng: 16.8373924}], 7)
# => "yemffFi`[email protected]{[email protected]}gi|gG"

Polylines.decode("yemffFi`[email protected]{[email protected]}gi|gG", 7)
# => [{lat: 12.1232493, lng: 2.9481493}, {lat: 13.8474392, lng: 16.8373924}]

Contributing

  1. Fork it (BuonOmo/polylines.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request