mapbaidu 0.0.3 → 0.0.4

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.
Files changed (2) hide show
  1. data/lib/map_baidu.rb +11 -50
  2. metadata +1 -1
data/lib/map_baidu.rb CHANGED
@@ -48,8 +48,9 @@ class MapBaiDu
48
48
 
49
49
  def round (distance)
50
50
 
51
- current_lat = self.get_lat.round(4)*10000.to_int
52
- current_lng = self.get_lng.round(4)*10000.to_int
51
+ current_lat = (self.get_lat.round(4)*10000).to_int
52
+ current_lng = (self.get_lng.round(4)*10000).to_int
53
+
53
54
 
54
55
  #result_array = Array.new()
55
56
  #begin_lng = (current_lng - (distance/100).to_int).to_i
@@ -76,26 +77,21 @@ class MapBaiDu
76
77
  while y >=0
77
78
  x = Math.sqrt(radius**2 - y**2).ceil.to_i
78
79
  while x >= 0
79
- result_array.push([(current_lng- x), (current_lat - (y+1))])
80
- result_array.push([(current_lng+ x), (current_lat - (y+1))])
80
+ result_array.push([(current_lng- x)/10000.to_f, (current_lat - (y+1))/10000.to_f])
81
+ result_array.push([(current_lng+ x)/10000.to_f, (current_lat - (y+1))/10000.to_f])
81
82
 
82
- result_array.push([(current_lng- x), (current_lat + (y+1))])
83
- result_array.push([(current_lng+ x), (current_lat + (y+1))])
83
+ result_array.push([(current_lng- x)/10000.to_f, (current_lat + (y+1))/10000.to_f])
84
+ result_array.push([(current_lng+ x)/10000.to_f, (current_lat + (y+1))/10000.to_f])
84
85
 
85
- result_array.push([(current_lng- x), (current_lat - (y))])
86
- result_array.push([(current_lng+ x), (current_lat + (y))])
86
+ result_array.push([(current_lng- x)/10000.to_f, (current_lat - (y))/10000.to_f])
87
+ result_array.push([(current_lng+ x)/10000.to_f, (current_lat + (y))/10000.to_f])
87
88
  x -= 1
88
89
  end
89
90
  y -=1
90
91
  end
91
-
92
-
93
- puts result_array.length == (2*radius + 1) **2
94
-
95
- return result_array
92
+ return result_array.uniq
96
93
  end
97
94
 
98
-
99
95
  def round_to_i(distance)
100
96
 
101
97
  result = Array.new
@@ -118,42 +114,7 @@ class MapBaiDu
118
114
  end
119
115
  end
120
116
 
121
- #
122
- #def round2(distance)
123
- #
124
- # current_lat = self.get_lat.round(4)*10000
125
- # current_lng = self.get_lng.round(4)*10000
126
- #
127
- # s_r = Array.new
128
- #
129
- # radius = (distance.to_f/100).ceil
130
- # puts 'radius:' << radius.to_s
131
- #
132
- # y = radius-1
133
- #
134
- # puts current_lng.to_s << ":" << current_lat.to_s
135
- # current_lng = current_lng.to_i
136
- # current_lat = current_lat.to_i
137
- #
138
- # while y >=0
139
- # x = Math.sqrt(radius**2 - y**2).ceil.to_i
140
- # while x >= 0
141
- # s_r.push([(current_lng- x), (current_lat - (y+1))])
142
- # s_r.push([(current_lng+ x), (current_lat - (y+1))])
143
- #
144
- # s_r.push([(current_lng- x), (current_lat + (y+1))])
145
- # s_r.push([(current_lng+ x), (current_lat + (y+1))])
146
- #
147
- # s_r.push([(current_lng- x), (current_lat - (y))])
148
- # s_r.push([(current_lng+ x), (current_lat + (y))])
149
- # x -= 1
150
- # end
151
- # y -=1
152
- # end
153
- #end
154
- #
155
- #
156
- #
117
+
157
118
 
158
119
 
159
120
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mapbaidu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: