mapbaidu 0.0.5 → 0.0.6

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 +35 -26
  2. metadata +3 -3
data/lib/map_baidu.rb CHANGED
@@ -42,7 +42,7 @@ class MapBaiDu
42
42
  return @result['result']['location']['lat']
43
43
  end
44
44
 
45
- def get_location
45
+ def get_location
46
46
  return @result['result']['location']
47
47
  end
48
48
 
@@ -51,20 +51,18 @@ class MapBaiDu
51
51
  current_lat = (self.get_lat.round(4)*10000).to_int
52
52
  current_lng = (self.get_lng.round(4)*10000).to_int
53
53
 
54
- #result_array = Array.new()
55
- #begin_lng = (current_lng - (distance/100).to_int).to_i
56
- #begin_lat = (current_lat - (distance/100).to_int).to_i
57
- #i = 0
58
- #loop_times = 2 * (distance/100).to_int + 1
59
- #
60
- #while i < loop_times
61
- # j=0
62
- # while j < loop_times
63
- # result_array.push([(begin_lng + i)/10000.to_f, (begin_lat + j)/10000.to_f])
64
- # j +=1
65
- # end
66
- # i +=1
67
- #end
54
+ return _get_round_base_lng_and_lat_and_distance(current_lat, current_lng, distance)
55
+ end
56
+
57
+ def round_base_lng_and_lat(distance, lng, lat)
58
+
59
+ current_lat = (lat.round(4)*10000).to_int
60
+ current_lng = (lng.round(4)*10000).to_int
61
+
62
+ return _get_round_base_lng_and_lat_and_distance(current_lat, current_lng, distance)
63
+ end
64
+
65
+ def _get_round_base_lng_and_lat_and_distance(current_lat, current_lng, distance)
68
66
  result_array = Array.new
69
67
  radius = (distance.to_f/100).ceil
70
68
 
@@ -88,16 +86,29 @@ class MapBaiDu
88
86
  return result_array.uniq
89
87
  end
90
88
 
89
+
91
90
  def round_to_i(distance)
92
91
 
93
92
  result = Array.new
94
93
  array = self.round(distance)
95
94
 
96
95
  array.each do |f|
97
- str = i_to_3(f[0]) << i_to_3(f[1])
96
+ str = i_to_3(f[0]) << i_to_3(f[1])
98
97
  result.push(str.to_i)
99
98
  end
100
99
 
100
+ return result
101
+ end
102
+
103
+ def round_base_lng_and_lat_to_i(distance, lng, lat)
104
+
105
+ result = Array.new
106
+ array = self.round_base_lng_and_lat(distance, lng, lat)
107
+
108
+ array.each do |f|
109
+ str = i_to_3(f[0]) << i_to_3(f[1])
110
+ result.push(str.to_i)
111
+ end
101
112
 
102
113
  return result
103
114
  end
@@ -111,17 +122,15 @@ class MapBaiDu
111
122
  end
112
123
 
113
124
 
125
+ def round_between (round1, round2)
126
+ if (round2 == round1)
127
+ return [];
128
+ end
129
+ min = [round1, round2].min
130
+ max = [round1, round2].max
114
131
 
115
- def round_between (round1 ,round2)
116
- if(round2 == round1)
117
- return [];
118
- end
119
- min = [round1,round2].min
120
- max = [round1,round2].max
121
-
122
- return self.round(max) -self.round(min)
123
- end
124
-
132
+ return self.round(max) -self.round(min)
133
+ end
125
134
 
126
135
 
127
136
  end
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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,9 +9,9 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-18 00:00:00.000000000 Z
12
+ date: 2013-05-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: ! 'range between two round '
14
+ description: ! 'you can get round base lng && lat '
15
15
  email: zhangfortune527@gmail.com
16
16
  executables: []
17
17
  extensions: []