fast-polylines 2.0.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.yardopts +7 -0
- data/CHANGELOG.md +55 -0
- data/README.md +31 -24
- data/ext/fast_polylines/extconf.rb +10 -0
- data/ext/fast_polylines/fast_polylines.c +66 -7
- data/lib/fast-polylines.rb +3 -0
- data/lib/fast_polylines/version.rb +1 -1
- data/lib/fast_polylines.rb +6 -4
- data/spec/fast-polylines_spec.rb +10 -0
- data/spec/fast_polylines_spec.rb +29 -4
- data/spec/spec_helper.rb +2 -1
- metadata +15 -9
- data/ext/fast_polylines/.gitignore +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fd26a9400977f70c17d07fbbc97484bc33fa5c2a876ec72739379b9650b00403
|
|
4
|
+
data.tar.gz: b2caa0bcaa90d269bd92b948b01ecc080c006a1304500edd1435513671a2b465
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7fb523730effba875e1eb7f557904bfdf11f44e419cbea433f11d29c73587b29956339075ac3b6af8f7e83de2a5b17241d93bb806f703a69f2ca81ff439fcd2a
|
|
7
|
+
data.tar.gz: 4311f966e39d44e47fd039712549466fa29a828f7470e5c33238f8997540f95327e2befd182bc79ceebfe9c5c728e001a41cd57ab7250ea80b676023a3a8913f
|
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--require spec_helper
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
# Changelog
|
|
3
|
+
|
|
4
|
+
All notable changes to this project will be documented in this file.
|
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
6
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
|
+
|
|
8
|
+
## [unreleased] —
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
## [2.2.2] — 2022-01-11
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- C API documentation.
|
|
21
|
+
|
|
22
|
+
## [2.2.0] — 2020-11-24
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- support for windows (#19 #23) by [@mohits]
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- Speedup calculation by avoiding calling pow(10,x) (#22) by [@mohits]
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- move from travis to github actions
|
|
35
|
+
|
|
36
|
+
[@mohits]: https://github.com/mohits
|
|
37
|
+
|
|
38
|
+
## [2.1.0] — 2020-04-30
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- A Require ptah that match the gem name (#18)
|
|
43
|
+
|
|
44
|
+
## [2.0.1] — 2020-04-02
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- Broken behavior when approaching the chunk size limit (#16)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
[unreleased]: https://github.com/klaxit/fast-polylines/compare/v2.2.2...HEAD
|
|
52
|
+
[2.2.2]: https://github.com/klaxit/fast-polylines/compare/v2.2.0...v2.2.2
|
|
53
|
+
[2.2.0]: https://github.com/klaxit/fast-polylines/compare/v2.1.0...v2.2.0
|
|
54
|
+
[2.1.0]: https://github.com/klaxit/fast-polylines/compare/v2.0.1...v2.1.0
|
|
55
|
+
[2.0.1]: https://github.com/klaxit/fast-polylines/compare/v2.0.0...v2.0.1
|
data/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Fast Polylines
|
|
2
2
|
|
|
3
|
-
[](https://rubygems.org/gems/fast-polylines)
|
|
4
|
+
[](https://github.com/klaxit/fast-polylines/actions?query=workflow%3A%22Continuous+Integration%22)
|
|
5
5
|
|
|
6
6
|
Implementation of the [Google polyline algorithm][algorithm].
|
|
7
7
|
|
|
8
|
-
**BREAKING CHANGES:** The version 2
|
|
8
|
+
**BREAKING CHANGES:** The version 2 of FastPolylines includes breaking changes, see [Migrate from V1](#migrate-from-V1)
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
About **300x faster encoding and decoding** than [Joshua Clayton's gem][polylines].
|
|
@@ -16,35 +16,35 @@ About **300x faster encoding and decoding** than [Joshua Clayton's gem][polylin
|
|
|
16
16
|
——————————————————————————————— ENCODING ————————————————————————————————
|
|
17
17
|
|
|
18
18
|
Warming up --------------------------------------
|
|
19
|
-
Polylines
|
|
20
|
-
FastPolylinesV1 2.
|
|
21
|
-
FastPolylinesV2
|
|
19
|
+
Polylines 310.000 i/100ms
|
|
20
|
+
FastPolylinesV1 2.607k i/100ms
|
|
21
|
+
FastPolylinesV2 59.833k i/100ms
|
|
22
22
|
Calculating -------------------------------------
|
|
23
|
-
Polylines
|
|
24
|
-
FastPolylinesV1 25.
|
|
25
|
-
FastPolylinesV2
|
|
23
|
+
Polylines 2.957k (± 5.9%) i/s - 14.880k in 5.049867s
|
|
24
|
+
FastPolylinesV1 25.644k (± 5.8%) i/s - 127.743k in 4.999954s
|
|
25
|
+
FastPolylinesV2 682.981k (± 7.7%) i/s - 3.410M in 5.025952s
|
|
26
26
|
|
|
27
27
|
Comparison:
|
|
28
|
-
FastPolylinesV2:
|
|
29
|
-
FastPolylinesV1:
|
|
30
|
-
Polylines:
|
|
28
|
+
FastPolylinesV2: 682980.7 i/s
|
|
29
|
+
FastPolylinesV1: 25643.7 i/s - 26.63x slower
|
|
30
|
+
Polylines: 2957.1 i/s - 230.97x slower
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
——————————————————————————————— DECODING ————————————————————————————————
|
|
34
34
|
|
|
35
35
|
Warming up --------------------------------------
|
|
36
|
-
Polylines
|
|
37
|
-
FastPolylinesV1 1.
|
|
38
|
-
FastPolylinesV2
|
|
36
|
+
Polylines 127.000 i/100ms
|
|
37
|
+
FastPolylinesV1 1.225k i/100ms
|
|
38
|
+
FastPolylinesV2 40.667k i/100ms
|
|
39
39
|
Calculating -------------------------------------
|
|
40
|
-
Polylines 1.
|
|
41
|
-
FastPolylinesV1
|
|
42
|
-
FastPolylinesV2
|
|
40
|
+
Polylines 1.289k (± 6.1%) i/s - 6.477k in 5.046552s
|
|
41
|
+
FastPolylinesV1 15.445k (± 4.4%) i/s - 77.175k in 5.006896s
|
|
42
|
+
FastPolylinesV2 468.413k (± 7.8%) i/s - 2.359M in 5.068936s
|
|
43
43
|
|
|
44
44
|
Comparison:
|
|
45
|
-
FastPolylinesV2:
|
|
46
|
-
FastPolylinesV1:
|
|
47
|
-
Polylines:
|
|
45
|
+
FastPolylinesV2: 468412.8 i/s
|
|
46
|
+
FastPolylinesV1: 15445.4 i/s - 30.33x slower
|
|
47
|
+
Polylines: 1288.8 i/s - 363.46x slower
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
## Install
|
|
@@ -61,7 +61,7 @@ gem "fast-polylines", "~> 2.0.0"
|
|
|
61
61
|
## Usage
|
|
62
62
|
|
|
63
63
|
```ruby
|
|
64
|
-
require "
|
|
64
|
+
require "fast_polylines"
|
|
65
65
|
|
|
66
66
|
FastPolylines.encode([[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]])
|
|
67
67
|
# "_p~iF~ps|U_ulLnnqC_mqNvxq`@"
|
|
@@ -74,7 +74,7 @@ FastPolylines.decode("_p~iF~ps|U_ulLnnqC_mqNvxq`@")
|
|
|
74
74
|
|
|
75
75
|
**Use a different precision**
|
|
76
76
|
|
|
77
|
-
Default precision is `5` decimals, to use a precision of `6
|
|
77
|
+
Default precision is `5` decimals, to use a precision of `6`:
|
|
78
78
|
```ruby
|
|
79
79
|
FastPolylines.encode([[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]], 6)
|
|
80
80
|
# "_izlhA~rlgdF_{geC~ywl@_kwzCn`{nI"
|
|
@@ -84,17 +84,21 @@ FastPolylines.decode("_izlhA~rlgdF_{geC~ywl@_kwzCn`{nI", 6)
|
|
|
84
84
|
```
|
|
85
85
|
The precision max is `13`.
|
|
86
86
|
|
|
87
|
-
##
|
|
87
|
+
## Migrate from V1
|
|
88
88
|
|
|
89
89
|
**TL;DR:**
|
|
90
90
|
|
|
91
91
|
```ruby
|
|
92
92
|
# before
|
|
93
|
+
require "fast-polylines"
|
|
93
94
|
FastPolylines::Encoder.encode([[1.2, 1.2], [2.4, 2.4]], 1e6)
|
|
94
95
|
# after
|
|
96
|
+
require "fast_polylines"
|
|
95
97
|
FastPolylines.encode([[1.2, 1.2], [2.4, 2.4]], 6)
|
|
96
98
|
```
|
|
97
99
|
|
|
100
|
+
**Detailled:**
|
|
101
|
+
|
|
98
102
|
The new version of `FastPolylines` doesn't support precision more than `1e13`,
|
|
99
103
|
you should not consider using it anyway since [it is way too precise][xkcd].
|
|
100
104
|
|
|
@@ -106,6 +110,9 @@ The precision is now an integer representing the number of decimals. It is
|
|
|
106
110
|
slightly smaller, and mostly this will avoid having any float value as
|
|
107
111
|
precision.
|
|
108
112
|
|
|
113
|
+
The file name to require is now snake_cased, you'll have to require
|
|
114
|
+
`fast_polylines`. The gem name stays the same however.
|
|
115
|
+
|
|
109
116
|
## Run the Benchmark
|
|
110
117
|
|
|
111
118
|
You can run the benchmark with `make benchmark`.
|
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Document-module: FastPolylines
|
|
3
|
+
*
|
|
4
|
+
* Implementation of the [Google polyline algorithm](https://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html).
|
|
5
|
+
*
|
|
6
|
+
* Install it with `gem install fast-polylines`, and then:
|
|
7
|
+
*
|
|
8
|
+
* require "fast_polylines"
|
|
9
|
+
*
|
|
10
|
+
* FastPolylines.encode([[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]])
|
|
11
|
+
* # "_p~iF~ps|U_ulLnnqC_mqNvxq`@"
|
|
12
|
+
*
|
|
13
|
+
* FastPolylines.decode("_p~iF~ps|U_ulLnnqC_mqNvxq`@")
|
|
14
|
+
* # [[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]]
|
|
15
|
+
*
|
|
16
|
+
* You can set an arbitrary precision for your coordinates to be encoded/decoded. It may be from 1
|
|
17
|
+
* to 13 decimal digits. However, 13 may be too much.
|
|
18
|
+
*
|
|
19
|
+
* [](https://www.explainxkcd.com/wiki/index.php/2170:_Coordinate_Precision)
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include <ruby.h>
|
|
2
23
|
|
|
3
24
|
// An encoded number can have at most _precision_ characters. However,
|
|
4
25
|
// it seems like we have a fuzzy behavior on low precisions. Hence a guard
|
|
@@ -24,6 +45,21 @@
|
|
|
24
45
|
#define rdbg(...)
|
|
25
46
|
#endif
|
|
26
47
|
|
|
48
|
+
typedef unsigned int uint;
|
|
49
|
+
|
|
50
|
+
// Speed up the code a bit by not calling pow(10.0, precision) since it is
|
|
51
|
+
// always 10^precision. Convert that into a lookup instead of doing the
|
|
52
|
+
// calculation.
|
|
53
|
+
// The precision parameter is already checked in +_get_precision()+ to ensure
|
|
54
|
+
// that it is within the range.
|
|
55
|
+
static inline double _fast_pow10(uint precision) {
|
|
56
|
+
const double lookup[MAX_PRECISION + 1] = {
|
|
57
|
+
1.0, 10.0, 1.0e+2, 1.0e+3, 1.0e+4, 1.0e+5, 1.0e+6, 1.0e+7,
|
|
58
|
+
1.0e+8, 1.0e+9, 1.0e+10, 1.0e+11, 1.0e+12, 1.0e+13
|
|
59
|
+
};
|
|
60
|
+
return lookup[precision];
|
|
61
|
+
}
|
|
62
|
+
|
|
27
63
|
static inline uint _get_precision(VALUE value) {
|
|
28
64
|
int precision = NIL_P(value) ? DEFAULT_PRECISION : NUM2INT(value);
|
|
29
65
|
if (precision > MAX_PRECISION) rb_raise(rb_eArgError, "precision too high (https://xkcd.com/2170/)");
|
|
@@ -31,13 +67,22 @@ static inline uint _get_precision(VALUE value) {
|
|
|
31
67
|
return (uint)precision;
|
|
32
68
|
}
|
|
33
69
|
|
|
34
|
-
|
|
70
|
+
/**
|
|
71
|
+
* call-seq:
|
|
72
|
+
* FastPolylines.decode(polyline, precision = 5) -> [[lat, lng], ...]
|
|
73
|
+
*
|
|
74
|
+
* Decode a polyline to a list of coordinates (lat, lng tuples). You may
|
|
75
|
+
* set an arbitrary coordinate precision, however, it **must match** the precision
|
|
76
|
+
* that was used for encoding.
|
|
77
|
+
*/
|
|
78
|
+
static VALUE
|
|
35
79
|
rb_FastPolylines__decode(int argc, VALUE *argv, VALUE self) {
|
|
36
80
|
rb_check_arity(argc, 1, 2);
|
|
37
81
|
Check_Type(argv[0], T_STRING);
|
|
38
82
|
char* polyline = StringValueCStr(argv[0]);
|
|
39
83
|
uint precision = _get_precision(argc > 1 ? argv[1] : Qnil);
|
|
40
|
-
double precision_value =
|
|
84
|
+
double precision_value = _fast_pow10(precision);
|
|
85
|
+
|
|
41
86
|
VALUE ary = rb_ary_new();
|
|
42
87
|
// Helps keeping track of whether we are computing lat (0) or lng (1).
|
|
43
88
|
uint8_t index = 0;
|
|
@@ -72,19 +117,30 @@ rb_FastPolylines__decode(int argc, VALUE *argv, VALUE self) {
|
|
|
72
117
|
|
|
73
118
|
static inline uint8_t
|
|
74
119
|
_polyline_encode_number(char *chunks, int64_t number) {
|
|
120
|
+
dbg("_polyline_encode_number(\"%s\", %lli)\n", chunks, number);
|
|
75
121
|
number = number < 0 ? ~(number << 1) : (number << 1);
|
|
76
122
|
uint8_t i = 0;
|
|
77
|
-
while (number
|
|
123
|
+
while (number >= 0x20) {
|
|
78
124
|
uint8_t chunk = number & 0x1f;
|
|
79
125
|
chunks[i++] = (0x20 | chunk) + 63;
|
|
80
126
|
number = number >> 5;
|
|
81
127
|
}
|
|
82
|
-
dbg("%u encoded chunks\n", i);
|
|
83
128
|
chunks[i++] = number + 63;
|
|
129
|
+
dbg("%u encoded chunks\n", i);
|
|
130
|
+
dbg("chunks: %s\n", chunks);
|
|
131
|
+
dbg("/_polyline_encode_number\n");
|
|
84
132
|
return i;
|
|
85
133
|
}
|
|
86
134
|
|
|
87
|
-
|
|
135
|
+
/**
|
|
136
|
+
* call-seq:
|
|
137
|
+
* FastPolylines.encode([[lat, lng], ...], precision = 5) -> string
|
|
138
|
+
*
|
|
139
|
+
* Encode a list of coordinates to a polyline, you may give a specific precision
|
|
140
|
+
* if you want to retain more (or less) than 5 digits of precision. The maximum
|
|
141
|
+
* is 13, and may really be [too much](https://xkcd.com/2170/).
|
|
142
|
+
*/
|
|
143
|
+
static VALUE
|
|
88
144
|
rb_FastPolylines__encode(int argc, VALUE *argv, VALUE self) {
|
|
89
145
|
rb_check_arity(argc, 1, 2);
|
|
90
146
|
Check_Type(argv[0], T_ARRAY);
|
|
@@ -95,7 +151,8 @@ rb_FastPolylines__encode(int argc, VALUE *argv, VALUE self) {
|
|
|
95
151
|
uint precision = _get_precision(argc > 1 ? argv[1] : Qnil);
|
|
96
152
|
dbg("rb_FastPolylines__encode(..., %u)\n", precision);
|
|
97
153
|
rdbg(argv[0]);
|
|
98
|
-
double precision_value =
|
|
154
|
+
double precision_value = _fast_pow10(precision);
|
|
155
|
+
|
|
99
156
|
// This is the maximum possible size the polyline may have. This
|
|
100
157
|
// being **without** null character. To copy it later as a Ruby
|
|
101
158
|
// string we'll have to use `rb_str_new` with the length.
|
|
@@ -108,6 +165,7 @@ rb_FastPolylines__encode(int argc, VALUE *argv, VALUE self) {
|
|
|
108
165
|
for (i = 0; i < len; i++) {
|
|
109
166
|
current_pair = RARRAY_AREF(argv[0], i);
|
|
110
167
|
uint8_t j;
|
|
168
|
+
Check_Type(current_pair, T_ARRAY);
|
|
111
169
|
if (RARRAY_LEN(current_pair) != 2) {
|
|
112
170
|
free(chunks);
|
|
113
171
|
rb_raise(rb_eArgError, "wrong number of coordinates");
|
|
@@ -136,6 +194,7 @@ rb_FastPolylines__encode(int argc, VALUE *argv, VALUE self) {
|
|
|
136
194
|
// We pass a pointer to the current chunk that need to be filled. Doing so
|
|
137
195
|
// avoid having to copy the string every single iteration.
|
|
138
196
|
chunks_index += _polyline_encode_number(chunks + chunks_index * sizeof(char), delta);
|
|
197
|
+
dbg("%s\n", chunks);
|
|
139
198
|
}
|
|
140
199
|
}
|
|
141
200
|
dbg("final chunks_index: %zu\n", chunks_index);
|
data/lib/fast_polylines.rb
CHANGED
|
@@ -3,17 +3,19 @@
|
|
|
3
3
|
require "fast_polylines/fast_polylines"
|
|
4
4
|
|
|
5
5
|
module FastPolylines::Encoder
|
|
6
|
-
|
|
6
|
+
# @deprecated Use {FastPolylines.encode} instead.
|
|
7
|
+
def self.encode(points, precision = 1e5)
|
|
7
8
|
warn "Deprecated use of `FastPolylines::Encoder.encode`, " \
|
|
8
|
-
|
|
9
|
+
"use `FastPolylines.encode`."
|
|
9
10
|
FastPolylines.encode(points, Math.log10(precision))
|
|
10
11
|
end
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
module FastPolylines::Decoder
|
|
14
|
-
|
|
15
|
+
# @deprecated Use {FastPolylines.decode} instead.
|
|
16
|
+
def self.decode(polyline, precision = 1e5)
|
|
15
17
|
warn "Deprecated use of `FastPolylines::Decoder.decode`, " \
|
|
16
|
-
|
|
18
|
+
"use `FastPolylines.decode`."
|
|
17
19
|
FastPolylines.decode(polyline, Math.log10(precision))
|
|
18
20
|
end
|
|
19
21
|
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require "fast-polylines"
|
|
2
|
+
|
|
3
|
+
describe FastPolylines do
|
|
4
|
+
let(:points) { [[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]] }
|
|
5
|
+
let(:polyline) { "_p~iF~ps|U_ulLnnqC_mqNvxq`@" }
|
|
6
|
+
it "should work with kebab-case requirement" do
|
|
7
|
+
expect(FastPolylines.encode(points)).to eq polyline
|
|
8
|
+
expect(FastPolylines.decode(polyline)).to eq points
|
|
9
|
+
end
|
|
10
|
+
end
|
data/spec/fast_polylines_spec.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "fast_polylines"
|
|
2
2
|
|
|
3
3
|
describe FastPolylines do
|
|
4
4
|
describe ".decode" do
|
|
5
5
|
let(:points) { [[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]] }
|
|
6
|
+
let(:polyline) { "_p~iF~ps|U_ulLnnqC_mqNvxq`@" }
|
|
6
7
|
context "with default precision" do
|
|
7
|
-
let(:polyline) { "_p~iF~ps|U_ulLnnqC_mqNvxq`@" }
|
|
8
8
|
it "should decode a polyline correctly" do
|
|
9
9
|
expect(described_class.decode(polyline)).to eq points
|
|
10
10
|
end
|
|
@@ -47,9 +47,34 @@ describe FastPolylines do
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
describe ".encode" do
|
|
50
|
-
let(:points)
|
|
50
|
+
let(:points) { [[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]] }
|
|
51
|
+
let(:polyline) { "_p~iF~ps|U_ulLnnqC_mqNvxq`@" }
|
|
52
|
+
it "should raise for invalid input" do
|
|
53
|
+
expect { described_class.encode(points[0]) }.to raise_error(
|
|
54
|
+
TypeError,
|
|
55
|
+
"wrong argument type Float (expected Array)"
|
|
56
|
+
)
|
|
57
|
+
expect { described_class.encode([points]) }.to raise_error(
|
|
58
|
+
ArgumentError,
|
|
59
|
+
"wrong number of coordinates"
|
|
60
|
+
)
|
|
61
|
+
expect { described_class.encode([points[0..1]]) }.to raise_error(
|
|
62
|
+
TypeError,
|
|
63
|
+
"no implicit conversion to Float from Array"
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
# The method `_polyline_encode_number("", 16)` will check for a chunk
|
|
67
|
+
# of the size 32, which is the chunk size limit. This was errored due to
|
|
68
|
+
# a bad sign.
|
|
69
|
+
# Reported in issue #15, closed in PR #16
|
|
70
|
+
context "with points close to the chunk size limit" do
|
|
71
|
+
let(:points) { [[0, 0.00016]] }
|
|
72
|
+
let(:polyline) { "?_@" }
|
|
73
|
+
it "should encode points correctly" do
|
|
74
|
+
expect(described_class.encode(points)).to eq polyline
|
|
75
|
+
end
|
|
76
|
+
end
|
|
51
77
|
context "with default precision" do
|
|
52
|
-
let(:polyline) { "_p~iF~ps|U_ulLnnqC_mqNvxq`@" }
|
|
53
78
|
it "should encode points correctly" do
|
|
54
79
|
expect(described_class.encode(points)).to eq polyline
|
|
55
80
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fast-polylines
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cyrille Courtière
|
|
8
8
|
- Ulysse Buonomo
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: benchmark-ips
|
|
@@ -53,7 +53,7 @@ dependencies:
|
|
|
53
53
|
- - "~>"
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
55
|
version: '3.5'
|
|
56
|
-
description:
|
|
56
|
+
description:
|
|
57
57
|
email:
|
|
58
58
|
- dev@klaxit.com
|
|
59
59
|
executables: []
|
|
@@ -61,19 +61,23 @@ extensions:
|
|
|
61
61
|
- ext/fast_polylines/extconf.rb
|
|
62
62
|
extra_rdoc_files: []
|
|
63
63
|
files:
|
|
64
|
+
- ".rspec"
|
|
65
|
+
- ".yardopts"
|
|
66
|
+
- CHANGELOG.md
|
|
64
67
|
- README.md
|
|
65
|
-
- ext/fast_polylines/.gitignore
|
|
66
68
|
- ext/fast_polylines/extconf.rb
|
|
67
69
|
- ext/fast_polylines/fast_polylines.c
|
|
70
|
+
- lib/fast-polylines.rb
|
|
68
71
|
- lib/fast_polylines.rb
|
|
69
72
|
- lib/fast_polylines/version.rb
|
|
73
|
+
- spec/fast-polylines_spec.rb
|
|
70
74
|
- spec/fast_polylines_spec.rb
|
|
71
75
|
- spec/spec_helper.rb
|
|
72
76
|
homepage: https://github.com/klaxit/fast-polylines
|
|
73
77
|
licenses:
|
|
74
78
|
- MIT
|
|
75
79
|
metadata: {}
|
|
76
|
-
post_install_message:
|
|
80
|
+
post_install_message:
|
|
77
81
|
rdoc_options: []
|
|
78
82
|
require_paths:
|
|
79
83
|
- lib
|
|
@@ -81,17 +85,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
81
85
|
requirements:
|
|
82
86
|
- - ">="
|
|
83
87
|
- !ruby/object:Gem::Version
|
|
84
|
-
version:
|
|
88
|
+
version: 2.4.6
|
|
85
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
90
|
requirements:
|
|
87
91
|
- - ">="
|
|
88
92
|
- !ruby/object:Gem::Version
|
|
89
93
|
version: '0'
|
|
90
94
|
requirements: []
|
|
91
|
-
rubygems_version: 3.
|
|
92
|
-
signing_key:
|
|
95
|
+
rubygems_version: 3.2.3
|
|
96
|
+
signing_key:
|
|
93
97
|
specification_version: 4
|
|
94
98
|
summary: Fast & easy Google polylines
|
|
95
99
|
test_files:
|
|
100
|
+
- spec/fast-polylines_spec.rb
|
|
96
101
|
- spec/fast_polylines_spec.rb
|
|
97
102
|
- spec/spec_helper.rb
|
|
103
|
+
- ".rspec"
|