pokeplot 0.2.0beta → 0.2.1beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f267bb552fa0249e0c8c72f00e0477b0f73a369
4
- data.tar.gz: 1d629d046753400c80398d81d96a1726d16f3be0
3
+ metadata.gz: 783b6d871e194ddb79a1ba44f86893574df1a9a8
4
+ data.tar.gz: 6a9adc4e25c11dbe450d0fddad949f5212855c29
5
5
  SHA512:
6
- metadata.gz: d099ee6b32fb7466ae3114e029cfd7e295f709a431077bd2a0836549ffdf15fdc69b83739b1fb76ef2df7d5d9e54c76430a6de8aba6b4d0b8ca14d92fbd5b99b
7
- data.tar.gz: 07b86dd8ff21294c85e826ba0be85573f44284fe200997aefe3e4d2824d9e61bf453009129a700ca4ac4672a328efb7040259b6d9a9f2e4e712ff4435f0f6280
6
+ metadata.gz: b9f4120d207703418fe37d903d1a7c9fac46ab8269a5588bea11a47ff1c946bb93855da6d6aafc4e20063bed661310b79bcc5b20455f2ffef65bcd7e27c75f08
7
+ data.tar.gz: a0feefd98681c52595c4b8d918dca06b9c661bbeb34e7e12d6e987bc6cc864cffa8cead62d9ab739e38175b1f5d57014e9550206c9e66bed28a08003aee538c3
data/README.md CHANGED
@@ -91,7 +91,7 @@ Pokeplot will be updated frequently, I have lots of spare time.
91
91
  If you have any problems using this, I will do whatever I can to help you get up and running. Your options are
92
92
 
93
93
  * Create an issue [HERE](https://github.com/xssc/pokeplot/issues)
94
- * Email me @ xssc820@gmail.com
94
+ * Email me @ xssc@protonmail.com
95
95
  * Or PM me on reddit at [/u/xssc](https://www.reddit.com/message/compose?to=xssc)
96
96
 
97
97
  ## Contributing
@@ -1,11 +1,130 @@
1
- require 'poke-api/helpers'
1
+ require 'poke-api'
2
+
3
+
4
+ module Poke
5
+ module API
6
+ module Geometry
7
+ module S2Base
8
+ POS_TO_ORIENTATION = [SWAP_MASK, 0, 0, INVERT_MASK | SWAP_MASK]
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ module Poke
15
+ module API
16
+ module Geometry
17
+ class S2CellId
18
+ include S2Base
19
+ def to_face_ij_orientation
20
+ i, j = 0, 0
21
+ face = self.face
22
+ bits = (face & SWAP_MASK)
23
+
24
+ 7.downto(0).each do |k|
25
+ if k == 7
26
+ nbits = (MAX_LEVEL - 7 * LOOKUP_BITS)
27
+ else
28
+ nbits = LOOKUP_BITS
29
+ end
30
+
31
+ bits += (
32
+ self.id >> (k * 2 * LOOKUP_BITS + 1) &
33
+ ((1 << (2 * nbits)) - 1)
34
+ ) << 2
35
+ bits = LOOKUP_IJ[bits]
36
+ i += (bits >> (LOOKUP_BITS + 2)) << (k * LOOKUP_BITS)
37
+ j += ((bits >> 2) & ((1 << LOOKUP_BITS) - 1)) << (k * LOOKUP_BITS)
38
+ bits &= (SWAP_MASK | INVERT_MASK)
39
+ end
40
+
41
+ fail unless 0 == POS_TO_ORIENTATION[2]
42
+ fail unless SWAP_MASK == POS_TO_ORIENTATION[0]
43
+ if (lsb & 0x1111111111111110) != 0
44
+ bits ^= SWAP_MASK
45
+ end
46
+ orientation = bits
47
+
48
+ return face, i, j, orientation
49
+ end
50
+
51
+ def face
52
+ return self.id >> POS_BITS
53
+ end
54
+
55
+ def from_face_ij(face, i, j)
56
+ n = face << (POS_BITS - 1)
57
+ bits = face & SWAP_MASK
58
+
59
+ 7.downto(0).each do |k|
60
+ mask = (1 << LOOKUP_BITS) - 1
61
+ bits += (((i >> (k * LOOKUP_BITS)) & mask) << (LOOKUP_BITS + 2))
62
+ bits += (((j >> (k * LOOKUP_BITS)) & mask) << 2)
63
+ bits = LOOKUP_POS[bits]
64
+ n |= (bits >> 2) << (k * 2 * LOOKUP_BITS)
65
+ bits &= (SWAP_MASK | INVERT_MASK)
66
+ end
67
+
68
+ @id = (n * 2 + 1)
69
+ self
70
+ end
71
+
72
+ def from_face_ij_wrap(face, i, j)
73
+ i = [-1, [MAX_SIZE, i].min].max
74
+ j = [-1, [MAX_SIZE, j].min].max
75
+
76
+ scale = 1.0 / MAX_SIZE
77
+ u = scale * ((i << 1) + 1 - MAX_SIZE)
78
+ v = scale * ((j << 1) + 1 - MAX_SIZE)
79
+
80
+ face, u, v = xyz_to_face_uv(face_uv_to_xyz(face, u, v))
81
+ return from_face_ij(
82
+ face,
83
+ st_to_ij(0.5 * (u + 1)),
84
+ st_to_ij(0.5 * (v + 1)),
85
+ )
86
+ end
87
+
88
+ def from_face_ij_same(face, i, j, same_face)
89
+ if same_face
90
+ return from_face_ij(face, i, j)
91
+ else
92
+ return from_face_ij_wrap(face, i, j)
93
+ end
94
+ end
95
+
96
+ end
97
+ end
98
+ end
99
+ end
100
+
2
101
  module Pokeplot
3
102
  module Helpers
4
103
  class CellIds
5
104
  class << self
6
105
 
7
106
  def get(lat, long)
8
- return ::Poke::API::Helpers.get_cells(lat, long)
107
+ s2_point = ::Poke::API::Geometry::S2LatLon.new(lat, long).to_point
108
+ origin = ::Poke::API::Geometry::S2CellId.from_point(s2_point).parent(15)
109
+ level = 15
110
+ max_level = 30
111
+ max_size = 1 << 30
112
+ size = 1 << max_level - level
113
+ face, i, j = origin.to_face_ij_orientation[0..2]
114
+
115
+ walk = [
116
+ origin.id,
117
+ origin.from_face_ij_same(face, i, j - size, j - size >= 0).parent(level).id,
118
+ origin.from_face_ij_same(face, i, j + size, j + size < max_size).parent(level).id,
119
+ origin.from_face_ij_same(face, i - size, j, i - size >= 0).parent(level).id,
120
+ origin.from_face_ij_same(face, i + size, j, i + size < max_size).parent(level).id,
121
+ origin.from_face_ij_same(face, i - size, j - size, j - size >= 0 && i - size >= 0).parent(level).id,
122
+ origin.from_face_ij_same(face, i + size, j - size, j - size >= 0 && i + size < max_size).parent(level).id,
123
+ origin.from_face_ij_same(face, i - size, j + size, j + size < max_size && i - size >= 0).parent(level).id,
124
+ origin.from_face_ij_same(face, i + size, j + size, j + size < max_size && i + size < max_size).parent(level).id
125
+ ]
126
+
127
+ return walk.sort
9
128
  end
10
129
 
11
130
  end
@@ -1,3 +1,3 @@
1
1
  module Pokeplot
2
- VERSION = "0.2.0beta"
2
+ VERSION = "0.2.1beta"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pokeplot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0beta
4
+ version: 0.2.1beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sawyer Charles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-12 00:00:00.000000000 Z
11
+ date: 2016-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra-contrib