grid-map 0.0.1 → 0.0.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.
- data/lib/grid-map.rb +4 -4
- data/lib/grid-map/version.rb +1 -1
- data/spec/grid-map_spec.rb +29 -39
- metadata +2 -2
data/lib/grid-map.rb
CHANGED
@@ -16,10 +16,10 @@ module GridMap
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.square radius, lat, lon, array = false
|
19
|
-
r = radius
|
20
|
-
x = (distance(
|
21
|
-
y = (distance(
|
22
|
-
[x, y] if array
|
19
|
+
r = radius/3
|
20
|
+
x = (distance(0, 0, lat, 0)/r).ceil
|
21
|
+
y = (distance(0, 0, 0, lon)/r).ceil
|
22
|
+
return [x, y] if array
|
23
23
|
{x: x, y: y}
|
24
24
|
end
|
25
25
|
end
|
data/lib/grid-map/version.rb
CHANGED
data/spec/grid-map_spec.rb
CHANGED
@@ -45,70 +45,60 @@ describe GridMap do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "square" do
|
48
|
-
it "should
|
49
|
-
GridMap::square(30, 0, 0)
|
50
|
-
GridMap::square(30, 0, 0)[:y].should == 1001876
|
48
|
+
it "should match" do
|
49
|
+
GridMap::square(30, 0, 0, true).should == [0, 0]
|
51
50
|
end
|
52
51
|
|
53
|
-
it "should
|
54
|
-
GridMap::square(30, 90, 0)
|
55
|
-
GridMap::square(30, 90, 0)[:y].should == 500938
|
52
|
+
it "should match" do
|
53
|
+
GridMap::square(30, 90, 0, true).should == [1001876, 0]
|
56
54
|
end
|
57
55
|
|
58
|
-
it "should
|
59
|
-
GridMap::square(30, 0, 180)
|
60
|
-
GridMap::square(30, 0, 180)[:y].should == 0
|
56
|
+
it "should match" do
|
57
|
+
GridMap::square(30, 0, 180, true).should == [0, 2003751]
|
61
58
|
end
|
62
59
|
|
63
|
-
it "should
|
64
|
-
GridMap::square(30, 90, 180)
|
65
|
-
GridMap::square(30, 90, 180)[:y].should == 500938
|
60
|
+
it "should match" do
|
61
|
+
GridMap::square(30, 90, 180, true).should == [1001876, 2003751]
|
66
62
|
end
|
67
63
|
|
68
|
-
it "should
|
69
|
-
GridMap::square(50,
|
70
|
-
GridMap::square(50, 0, 0)[:y].should == 601126
|
64
|
+
it "should match" do
|
65
|
+
GridMap::square(50, 90, 180, true).should == [601126, 1202251]
|
71
66
|
end
|
72
67
|
|
73
|
-
it "should
|
74
|
-
GridMap::square(100,
|
75
|
-
GridMap::square(100, 0, 0)[:y].should == 300563
|
68
|
+
it "should match" do
|
69
|
+
GridMap::square(100, 90, 180, true).should == [300563, 601126]
|
76
70
|
end
|
77
71
|
|
78
|
-
it "should
|
79
|
-
GridMap::square(200,
|
80
|
-
GridMap::square(200, 0, 0)[:y].should == 150282
|
72
|
+
it "should match" do
|
73
|
+
GridMap::square(200, 90, 180, true).should == [150282, 300563]
|
81
74
|
end
|
82
75
|
|
83
|
-
it "should
|
84
|
-
GridMap::square(300,
|
85
|
-
GridMap::square(300, 0, 0)[:y].should == 100188
|
76
|
+
it "should match" do
|
77
|
+
GridMap::square(300, 90, 180, true).should == [100188, 200376]
|
86
78
|
end
|
87
79
|
|
88
|
-
it "should
|
89
|
-
GridMap::square(500,
|
90
|
-
GridMap::square(500, 0, 0)[:y].should == 60113
|
80
|
+
it "should match" do
|
81
|
+
GridMap::square(500, 90, 180, true).should == [60113, 120226]
|
91
82
|
end
|
92
83
|
|
93
|
-
it "should
|
94
|
-
GridMap::square(1000,
|
95
|
-
GridMap::square(1000, 0, 0)[:y].should == 30057
|
84
|
+
it "should match" do
|
85
|
+
GridMap::square(1000, 90, 180, true).should == [30057, 60113]
|
96
86
|
end
|
97
87
|
|
98
|
-
it "should
|
99
|
-
GridMap::square(2000,
|
100
|
-
GridMap::square(2000, 0, 0)[:y].should == 15029
|
88
|
+
it "should match" do
|
89
|
+
GridMap::square(2000, 90, 180, true).should == [15029, 30057]
|
101
90
|
end
|
102
91
|
|
103
|
-
it "should
|
104
|
-
GridMap::square(3000,
|
105
|
-
GridMap::square(3000, 0, 0)[:y].should == 10019
|
92
|
+
it "should match" do
|
93
|
+
GridMap::square(3000, 90, 180, true).should == [10019, 20038]
|
106
94
|
end
|
107
95
|
|
108
|
-
it "should
|
109
|
-
GridMap::square(5000,
|
110
|
-
GridMap::square(5000, 0, 0)[:y].should == 6012
|
96
|
+
it "should match" do
|
97
|
+
GridMap::square(5000, 90, 180, true).should == [6012, 12023]
|
111
98
|
end
|
112
99
|
|
100
|
+
it "should match" do
|
101
|
+
GridMap::square(100, 40.4245895, -3.6494852, true).should == [135002, 12188]
|
102
|
+
end
|
113
103
|
end
|
114
104
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grid-map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|