quadkey 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -4
- data/lib/quadkey.rb +16 -0
- data/lib/quadkey/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f4a1fd676cad1fdbdec8c8a04779074a9f31bfd
|
4
|
+
data.tar.gz: d38abcdbba48b1d0c27de70a82fe8f0f6c1ee628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aac592cc2612a051a82924578c814840c652300325db8c8c8e9e406accdf93b8f26b216cd230f15528559c660bc5dd5ad7cd29003deafc3204493773510d659
|
7
|
+
data.tar.gz: b4c8c58aa4642195cb4d1cff7c1d1f562dc936130704d24f679238ec2d634d6cb1b384feb7193d261f76b9851625a61c0fd036afb18b459bafadf8b162fd6483
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Quadkey
|
1
|
+
# Quadkey [![Build Status](https://travis-ci.org/deg84/quadkey.svg?branch=master)](https://travis-ci.org/deg84/quadkey)
|
2
2
|
|
3
3
|
Based off of https://msdn.microsoft.com/en-us/library/bb259689.aspx
|
4
4
|
|
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
### encode
|
24
24
|
|
25
|
-
```
|
25
|
+
```ruby
|
26
26
|
latitude = 35.657976
|
27
27
|
longitude = -139.745364
|
28
28
|
precision = 16
|
@@ -32,10 +32,16 @@ quadkey = Quadkey.encode(latitude, longitude, precision)
|
|
32
32
|
|
33
33
|
### decode
|
34
34
|
|
35
|
-
```
|
35
|
+
```ruby
|
36
36
|
(latitude, longitude, precision) = Quadkey.decode('0221130032120022')
|
37
37
|
```
|
38
38
|
|
39
|
+
### neighbors
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
Quadkey.neighbors('0221130032120022')
|
43
|
+
```
|
44
|
+
|
39
45
|
## Development
|
40
46
|
|
41
47
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -44,7 +50,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
44
50
|
|
45
51
|
## Contributing
|
46
52
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/deg84/quadkey. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
48
54
|
|
49
55
|
|
50
56
|
## License
|
data/lib/quadkey.rb
CHANGED
@@ -20,6 +20,22 @@ module Quadkey
|
|
20
20
|
return latitude, longitude, precision
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.neighbors(quadkey)
|
24
|
+
tile_x, tile_y, precision = quadkey_to_tile(quadkey)
|
25
|
+
neighbors = []
|
26
|
+
permutation = [
|
27
|
+
[-1, -1], [0, -1], [1, -1],
|
28
|
+
[-1, 0], [0, 0], [1, 0],
|
29
|
+
[-1, 1], [0, 1], [1, 1]
|
30
|
+
]
|
31
|
+
permutation.each do |value|
|
32
|
+
perm_x, perm_y = value
|
33
|
+
neighbors << tile_to_quadkey(tile_x + perm_x, tile_y + perm_y, precision)
|
34
|
+
end
|
35
|
+
|
36
|
+
return neighbors
|
37
|
+
end
|
38
|
+
|
23
39
|
def self.clip(n, min_value, max_value)
|
24
40
|
[[n, min_value].max, max_value].min
|
25
41
|
end
|
data/lib/quadkey/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quadkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- deg84
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|