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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ed01b74f0efb1a3f47426fbc509646a9b1821ef
4
- data.tar.gz: bb6cfdb3a02f16861511d4c338343753d2d7c20d
3
+ metadata.gz: 4e450c609793d078954606f921497f207ac57529
4
+ data.tar.gz: 774bc01a02e7149fc896b4307bd712c248a235d6
5
5
  SHA512:
6
- metadata.gz: 88759345df8cf55c2b24766fc94d1484d49aaefb92f06395f6d2cfe75bdca16b1b2b6b61dbbfb860410061cc82a807e6c37fbda21f05c612131af4a67b5f91d8
7
- data.tar.gz: d29fc39a1d7b99d5b7f1f38d57e8c43567b0101972a5b6afc611e89c4c9c72a293438a970a4b79e6cac843a1da5912f4645d911a19ce7c08890ed3db63f43866
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["place"]["Data"] || result_data["New_addrs"]["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 results. we are using default.
202
- # places is for number of results
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"
@@ -1,5 +1,5 @@
1
1
  module Geocoder
2
2
  module Olleh
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -131,7 +131,7 @@ module Geocoder::Result
131
131
  ##
132
132
  # 법정동 - 시군구
133
133
  def addr_step_sigungu
134
- @data["SIGUNGU"].gsub("+"," ")
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"].gsub("+", " ")
173
- elsif data["M_ADDR1"]
174
- @data["M_ADDR1"].gsub("+", " ").gsub(" ", " ") + " " +
175
- @data["M_ADDR2"].gsub("+", " ").gsub(" ", " ")
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
- @data["NEW_ADDR"].gsub("+", " ")
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"].gsub("+", " ").gsub(" ", " ")
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
- @data["ADDR"]
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.0
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-01 00:00:00.000000000 Z
11
+ date: 2015-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler