mapbaidu 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/map_baidu.rb +53 -1
- metadata +5 -4
data/lib/map_baidu.rb
CHANGED
@@ -42,10 +42,62 @@ class MapBaiDu
|
|
42
42
|
return self.result()['result']['location']['lat']
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
def get_location
|
46
46
|
return self.result()['result']['location']
|
47
47
|
end
|
48
48
|
|
49
|
+
def round (distance)
|
50
|
+
|
51
|
+
current_lat = self.get_lat.round(4)*10000
|
52
|
+
current_lng = self.get_lng.round(4)*10000
|
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
|
68
|
+
|
69
|
+
return result_array
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def round_to_i(distance)
|
74
|
+
|
75
|
+
result = Array.new
|
76
|
+
array = self.round(distance)
|
77
|
+
|
78
|
+
array.each do |f|
|
79
|
+
str = i_to_3(f[0]) << i_to_3(f[1])
|
80
|
+
result.push(str.to_i)
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
return result
|
85
|
+
end
|
86
|
+
|
87
|
+
def i_to_3(number)
|
88
|
+
if number < 100
|
89
|
+
return '0'<< ((number*10000).to_i).to_s
|
90
|
+
else
|
91
|
+
return (number*10000).to_i.to_s
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
49
101
|
end
|
50
102
|
|
51
103
|
|
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.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,9 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: get
|
14
|
+
description: ! 'get [[lgn,lat]...[lgn,lat]] base current location use round and you
|
15
|
+
can get [lgnlat..lgnlat] use round_to_i '
|
15
16
|
email: zhangfortune527@gmail.com
|
16
17
|
executables: []
|
17
18
|
extensions: []
|
@@ -41,5 +42,5 @@ rubyforge_project:
|
|
41
42
|
rubygems_version: 1.8.25
|
42
43
|
signing_key:
|
43
44
|
specification_version: 3
|
44
|
-
summary:
|
45
|
+
summary: get info from map of baidu
|
45
46
|
test_files: []
|