geocoder-olleh 0.3.0 → 0.3.1
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.
- checksums.yaml +4 -4
- data/lib/geocoder/lookups/olleh.rb +23 -3
- data/lib/geocoder/olleh/version.rb +1 -1
- data/lib/geocoder/results/olleh.rb +16 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e450c609793d078954606f921497f207ac57529
|
4
|
+
data.tar.gz: 774bc01a02e7149fc896b4307bd712c248a235d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a58523125d3daf120d9a3347be033a9759bfb7f47329cb225d55416c7516087eb0b57002f1a847ba5d3b2903302cf592f38f49da7dba7079ff1f94c69d78f37
|
7
|
+
data.tar.gz: 8999a16b53c4d87cb06d454b5faee72c25140f5c5bc758b24cf6b149029f9b8b4dc8e56e631924b300f65f5647d882e362e4cc2b4d766c612b7f12a0a4ead3bf
|
@@ -140,6 +140,7 @@ module Geocoder::Lookup
|
|
140
140
|
def results(query)
|
141
141
|
data = fetch_data(query)
|
142
142
|
return [] unless data
|
143
|
+
return [] if data["payload"].empty?
|
143
144
|
return [] if data["error"]
|
144
145
|
doc = JSON.parse(URI.decode(data["payload"]))
|
145
146
|
if doc['ERRCD'] != nil && doc['ERRCD'] != 0
|
@@ -173,7 +174,15 @@ module Geocoder::Lookup
|
|
173
174
|
end
|
174
175
|
|
175
176
|
def local_search_result(result_data)
|
176
|
-
result_data["
|
177
|
+
if result_data["addr"] && !result_data["addr"]["Data"].empty?
|
178
|
+
result_data["addr"]["Data"]
|
179
|
+
elsif result_data["New_addrs"] && !result_data["New_addrs"]["Data"].empty?
|
180
|
+
result_data["New_addrs"]["Data"]
|
181
|
+
elsif result_data["place"] && !result_data["place"]["Data"].empty?
|
182
|
+
result_data["place"]["Data"]
|
183
|
+
else
|
184
|
+
nil
|
185
|
+
end
|
177
186
|
end
|
178
187
|
|
179
188
|
def base_url(query)
|
@@ -198,13 +207,24 @@ module Geocoder::Lookup
|
|
198
207
|
def query_url_params(query)
|
199
208
|
case Olleh.check_query_type(query)
|
200
209
|
when "addr_local_search"
|
201
|
-
# option 2 is for sorting
|
202
|
-
#
|
210
|
+
# option 2 is for sorting based on location of user.
|
211
|
+
# we are using default. "1"
|
212
|
+
#
|
213
|
+
# we can add UTMK X, Y coordinates for that.
|
214
|
+
# but i am not using it. it's optional.
|
215
|
+
# isarea = 1 should be used in this case.
|
216
|
+
# r is for setting radius. (300, 500, 1000, 2000, 40000)
|
217
|
+
#
|
218
|
+
# places is for number of results. 100 is the maximum.
|
219
|
+
#
|
203
220
|
# sr is for
|
204
221
|
# isaddr for searching address only. excluding building name, etc.
|
222
|
+
# s: "AN" means it will return old / new style addresses.
|
223
|
+
#
|
205
224
|
hash = {
|
206
225
|
query: URI.encode(query.text),
|
207
226
|
option: "1",
|
227
|
+
s: "AN",
|
208
228
|
places: query.options[:places],
|
209
229
|
sr: query.options[:sr],
|
210
230
|
isaddr: Olleh.new_addr_search_options[query.options[:isaddr]] || "1"
|
@@ -131,7 +131,7 @@ module Geocoder::Result
|
|
131
131
|
##
|
132
132
|
# 법정동 - 시군구
|
133
133
|
def addr_step_sigungu
|
134
|
-
@data["SIGUNGU"]
|
134
|
+
sanitize_addr(@data["SIGUNGU"])
|
135
135
|
end
|
136
136
|
|
137
137
|
def addr_step_dong
|
@@ -169,12 +169,13 @@ module Geocoder::Result
|
|
169
169
|
# using old address system
|
170
170
|
def old_addr
|
171
171
|
if @data["ADDR"]
|
172
|
-
@data["ADDR"]
|
173
|
-
elsif data["
|
174
|
-
@data["
|
175
|
-
|
172
|
+
sanitize_addr(@data["ADDR"])
|
173
|
+
elsif @data["ADDRESS"]
|
174
|
+
sanitize_addr(@data["ADDRESS"])
|
175
|
+
elsif @data["M_ADDR1"]
|
176
|
+
sanitize_addr(@data["M_ADDR1"]) + " " + sanitize_addr(@data["M_ADDR2"])
|
176
177
|
else
|
177
|
-
|
178
|
+
""
|
178
179
|
end
|
179
180
|
end
|
180
181
|
|
@@ -183,9 +184,11 @@ module Geocoder::Result
|
|
183
184
|
# using new address system
|
184
185
|
def new_addr
|
185
186
|
if @data["NEW_ADDR"]
|
186
|
-
@data["NEW_ADDR"]
|
187
|
+
sanitize_addr(@data["NEW_ADDR"])
|
188
|
+
elsif @data["M_NEWADDR1"] && @data["M_NEWADDR2"]
|
189
|
+
sanitize_addr(@data["M_NEWADDR1"]) + " " + sanitize_addr(@data["M_NEWADDR2"])
|
187
190
|
else
|
188
|
-
|
191
|
+
""
|
189
192
|
end
|
190
193
|
end
|
191
194
|
|
@@ -207,6 +210,11 @@ module Geocoder::Result
|
|
207
210
|
@data["Y"]
|
208
211
|
end
|
209
212
|
|
213
|
+
def sanitize_addr(text)
|
214
|
+
return unless text
|
215
|
+
text.gsub("++", " ").gsub("+", " ")
|
216
|
+
end
|
217
|
+
|
210
218
|
response_attributes.each do |a|
|
211
219
|
define_method a do
|
212
220
|
@data[a]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geocoder-olleh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaigouk Kim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|