geocoder-olleh 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: beddb48bf5e2d6be49933a3c6f6ea2b05ff968c7
4
- data.tar.gz: 9485bb8561762d4922ab66b0177a204ea35ca470
3
+ metadata.gz: d2afc3e7667878e6845e61eba31f0281ad67c123
4
+ data.tar.gz: 306fa16f547805908e9976878b9de9a7d0e1e7c9
5
5
  SHA512:
6
- metadata.gz: 35157961515bad6c9be77d6ec788f2276a57e7869bd261ec587d9b4672a2e931dd9ed709b8d12a37f349a7611bc609e6b2186a2aeb422d3974a6ae4e06a87a3f
7
- data.tar.gz: 37cd32862b1a257b6940015ca3d5cefa927c052490c6162c0f0221b040a0ca2d529893dbfdfb8d25e5c40623eddebbda2d6aa6563ff4ae415867e1670477d40f
6
+ metadata.gz: f16ad4659d8e5dc909eaa4d0bba1f5c03878f0e4245ea17bb98e9af49f950508c7c97bbabfa759191168977fea4154e2c400c77639ac72f1968379705cb4c4d5
7
+ data.tar.gz: e148fbf059d6726aef6587351876686962ae4775802e8ec3006b574173527c97ccce516a7a349d2b2933f286dc74847cf1c8f4217428b9370dbb3d91fffcb3bc
@@ -0,0 +1,74 @@
1
+ ## Way to send out - valid request
2
+
3
+ * Request URL : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22UTF-8_Address%22,%22s%22=%22AN%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%220%22}`
4
+
5
+ * "s"="AN" : Return both of old and new addresses
6
+ * "sr":"RANK" : Give high priority to the accuracy
7
+ * "places":"5" : Number of address that want to get returned
8
+ * "option":"2" : Distance based result alignment from current location
9
+ * "isaddr":"0", "isaddr":"1" : Search from address DB or not (0 : No, 1 : Yes)
10
+
11
+ ## Search queries from end users
12
+
13
+ 1) POI search
14
+
15
+ * KeyWord1 : 국민은행
16
+ * KeyWord2 : 서울 국민은행
17
+ * KeyWord3 : 서초동 강남미래타워
18
+
19
+ - Valid query1 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EA%25B5%25AD%25EB%25AF%25BC%25EC%259D%2580%25ED%2596%2589%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%220%22}`
20
+ - Valid query2 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EC%2584%259C%25EC%259A%25B8+%25EA%25B5%25AD%25EB%25AF%25BC%25EC%259D%2580%25ED%2596%2589%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%220%22}`
21
+ - Valid query3 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EC%2584%259C%25EC%25B4%2588%25EB%258F%2599+%25EA%25B0%2595%25EB%2582%25A8%25EB%25AF%25B8%25EB%259E%2598%25ED%2583%2580%25EC%259B%258C%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%220%22}`
22
+
23
+ 2) Old address search (With Gibun or without Gibun)
24
+
25
+ * KeyWord1 : 삼평동
26
+ * KeyWord2 : 삼평동 689
27
+ * KeyWord3 : 분당구 689
28
+ * KeyWord4 : 분당구 삼평동 689
29
+ * KeyWord5 : 성남시 분당구 삼평동 689
30
+ * KeyWord6 : 경기 성남시 분당구 삼평동 689
31
+ * KeyWord7 : 경기도 성남시 분당구 삼평동 689
32
+
33
+ - Valid query1 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EC%2582%25BC%25ED%258F%2589%25EB%258F%2599%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%220%22}`
34
+ - Valid query2 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EC%2582%25BC%25ED%258F%2589%25EB%258F%2599+689%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%220%22}`
35
+ - Valid query3 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EB%25B6%2584%25EB%258B%25B9%25EA%25B5%25AC+689%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%221%22}`
36
+ - Valid query4 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EB%25B6%2584%25EB%258B%25B9%25EA%25B5%25AC+%25EC%2582%25BC%25ED%258F%2589%25EB%258F%2599+689%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%220%22}`
37
+ - Valid query5 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EC%2584%25B1%25EB%2582%25A8%25EC%258B%259C+%25EB%25B6%2584%25EB%258B%25B9%25EA%25B5%25AC+%25EC%2582%25BC%25ED%258F%2589%25EB%258F%2599+689%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%220%22}`
38
+ - Valid query6 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EA%25B2%25BD%25EA%25B8%25B0+%25EC%2584%25B1%25EB%2582%25A8%25EC%258B%259C+%25EB%25B6%2584%25EB%258B%25B9%25EA%25B5%25AC+%25EC%2582%25BC%25ED%258F%2589%25EB%258F%2599+689%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%220%22}`
39
+ - Valid query7 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EA%25B2%25BD%25EA%25B8%25B0%25EB%258F%2584+%25EC%2584%25B1%25EB%2582%25A8%25EC%258B%259C+%25EB%25B6%2584%25EB%258B%25B9%25EA%25B5%25AC+%25EC%2582%25BC%25ED%258F%2589%25EB%258F%2599+689%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%220%22}`
40
+
41
+ 3) New address search (With street number or without street number)
42
+
43
+ * KeyWord1 : 사임당로
44
+ * KeyWord2 : 사임당로 174
45
+ * KeyWord3 : 서초구 사임당로 174
46
+ * KeyWord4 : 서울 서초구 사임당로 174
47
+ * KeyWord5 : 서울시 서초구 사임당로 174
48
+
49
+ - Valid query1 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EC%2582%25AC%25EC%259E%2584%25EB%258B%25B9%25EB%25A1%259C%22,%22s%22=%22AN%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%221%22}`
50
+ - Valid query2 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EC%2582%25AC%25EC%259E%2584%25EB%258B%25B9%25EB%25A1%259C+174%22,%22s%22=%22AN%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%221%22}`
51
+ - Valid query3 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EC%2584%259C%25EC%25B4%2588%25EB%258F%2599+%25EC%2582%25AC%25EC%259E%2584%25EB%258B%25B9%25EB%25A1%259C+174%22,%22s%22=%22AN%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%221%22}`
52
+ - Valid query4 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EC%2584%259C%25EC%259A%25B8+%25EC%2584%259C%25EC%25B4%2588%25EB%258F%2599+%25EC%2582%25AC%25EC%259E%2584%25EB%258B%25B9%25EB%25A1%259C+174%22,%22s%22=%22AN%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%221%22}`
53
+ - Valid query5 : `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22%25EC%2584%259C%25EC%259A%25B8%25EC%258B%259C+%25EC%2584%259C%25EC%25B4%2588%25EB%258F%2599+%25EC%2582%25AC%25EC%259E%2584%25EB%258B%25B9%25EB%25A1%259C+174%22,%22s%22=%22AN%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%221%22}`
54
+
55
+ ## Data to be taken
56
+
57
+ * Old address : address from "ADDR" or "M_ADDR1" + "M_ADDR2"
58
+ * New address : address from "NEW_ADDR"
59
+
60
+ * Coordinates
61
+ "Y":"1933916.06","H_CODE":"4113565500","X":"965566.75"
62
+
63
+ * Procedure to query address
64
+
65
+ Search address with "s"="AN" & "isaddr":"1"
66
+ `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22UTF-8_Address%22,%22s%22=%22AN%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%221%22}`
67
+
68
+ Search address with "isaddr":"1"
69
+ `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22UTF-8_Address%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%221%22}`
70
+
71
+ Search address with "isaddr":"0"
72
+ `http://openapi.kt.com/maps/search/km2_LocalSearch?params={%22query%22:%22UTF-8_Address%22,%22sr%22:%22RANK%22,%22places%22:%225%22,%22option%22:%222%22,%22timestamp%22:%2220120413092033765%22,%22isaddr%22:%220%22}`
73
+
74
+ If all above 3 returns no address it means there is no available results for the * keyword
@@ -113,6 +113,8 @@ module Geocoder::Lookup
113
113
  'convert_coord'
114
114
  when options.include?(:l_code)
115
115
  'addr_step_search'
116
+ when options.include?(:places)
117
+ 'addr_local_search'
116
118
  when options.include?(:radius)
117
119
  'addr_nearest_position_search'
118
120
  else
@@ -128,6 +130,7 @@ module Geocoder::Lookup
128
130
  def results(query)
129
131
  data = fetch_data(query)
130
132
  return [] unless data
133
+ return [] if data["error"]
131
134
  doc = JSON.parse(URI.decode(data["payload"]))
132
135
  if doc['ERRCD'] != nil && doc['ERRCD'] != 0
133
136
  Geocoder.log(:warn, "Olleh API error: #{doc['ERRCD']} (#{doc['ERRMS'] if doc['ERRMS']}).")
@@ -135,20 +138,23 @@ module Geocoder::Lookup
135
138
  end
136
139
 
137
140
  case Olleh.check_query_type(query)
138
- when "geocoding"
141
+ when 'addr_local_search'
142
+ return [] if doc["RESULTDATA"]["place"]["TotalCount"].to_i == 0
143
+ return doc["RESULTDATA"]["place"]["Data"]
144
+ when 'geocoding'
139
145
  return [] if doc['RESDATA']['COUNT'] == 0
140
- return doc['RESDATA']["ADDRS"]
141
- when "reverse_geocoding"
146
+ return doc['RESDATA']['ADDRS']
147
+ when 'reverse_geocoding'
142
148
  return [] if doc['RESDATA']['COUNT'] == 0
143
- return doc['RESDATA']["ADDRS"] || []
144
- when "route_search"
145
- return [] if doc["RESDATA"]["SROUTE"]["isRoute"] == "false"
146
- return doc["RESDATA"] || []
147
- when "convert_coord"
149
+ return doc['RESDATA']['ADDRS'] || []
150
+ when 'route_search'
151
+ return [] if doc['RESDATA']['SROUTE']['isRoute'] == 'false'
148
152
  return doc['RESDATA'] || []
149
- when "addr_step_search"
153
+ when 'convert_coord'
154
+ return doc['RESDATA'] || []
155
+ when 'addr_step_search'
150
156
  return doc['RESULTDATA'] || []
151
- when "addr_nearest_position_search"
157
+ when 'addr_nearest_position_search'
152
158
  return doc['RESULTDATA'] || []
153
159
  else
154
160
  []
@@ -157,6 +163,8 @@ module Geocoder::Lookup
157
163
 
158
164
  def base_url(query)
159
165
  case Olleh.check_query_type(query)
166
+ when "addr_local_search"
167
+ "https://openapi.kt.com/maps/search/km2_LocalSearch?params="
160
168
  when "route_search"
161
169
  "https://openapi.kt.com/maps/etc/RouteSearch?params="
162
170
  when "reverse_geocoding"
@@ -174,6 +182,18 @@ module Geocoder::Lookup
174
182
 
175
183
  def query_url_params(query)
176
184
  case Olleh.check_query_type(query)
185
+ when "addr_local_search"
186
+ # option 2 is for sorting results. we are using default.
187
+ # places is for number of results
188
+ # sr is for
189
+ # isaddr for searching address only. excluding building name, etc.
190
+ hash = {
191
+ query: URI.encode(query.text),
192
+ option: "1",
193
+ places: query.options[:places],
194
+ sr: query.options[:sr],
195
+ isaddr: "1"
196
+ }
177
197
  when "route_search"
178
198
  hash = {
179
199
  SX: query.options[:start_x],
@@ -1,5 +1,5 @@
1
1
  module Geocoder
2
2
  module Olleh
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
4
4
  end
5
5
  end
@@ -164,6 +164,38 @@ module Geocoder::Result
164
164
  "#{@data['SIDO']} #{@data['L_SIGUN_GU']} #{@data['L_DONG']} #{@data['GIBUN']}"
165
165
  end
166
166
 
167
+ ##
168
+ # addr used when we call km2_LocalSearch
169
+ # using old address system
170
+ def addr
171
+ @data["ADDR"].gsub("+", " ")
172
+ end
173
+
174
+ ##
175
+ # addr used when we call km2_LocalSearch
176
+ # using new address system
177
+ def new_addr
178
+ @data["NEW_ADDR"].gsub("+", " ")
179
+ end
180
+
181
+ ##
182
+ # NAME used when we call km2_LocalSearch
183
+ def name
184
+ @data["NAME"]
185
+ end
186
+
187
+ ##
188
+ # UTMK X coordinate used when we call km2_LocalSearch
189
+ def x
190
+ @data["X"]
191
+ end
192
+
193
+ ##
194
+ # UTMK Y coordinate used when we call km2_LocalSearch
195
+ def y
196
+ @data["Y"]
197
+ end
198
+
167
199
  response_attributes.each do |a|
168
200
  define_method a do
169
201
  @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.2.3
4
+ version: 0.2.4
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-07-23 00:00:00.000000000 Z
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,6 +55,7 @@ files:
55
55
  - bin/console
56
56
  - bin/setup
57
57
  - geocoder-olleh.gemspec
58
+ - km2_LocalSearch.md
58
59
  - lib/geocoder/lookups/olleh.rb
59
60
  - lib/geocoder/olleh.rb
60
61
  - lib/geocoder/olleh/lookup.rb