geocoder-olleh 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e980bb5259b8419b037935ee073106608216b1f
4
+ data.tar.gz: 2f65c59efa8fda13a11aea01f0c7962d361788b5
5
+ SHA512:
6
+ metadata.gz: 4b615dcc6ea40eaae380d6bf067ef149f798708beace506f2b544e4a0c24b5a7d6319cee64c5d88754cbf55aefb00eaebf9d527fd5c3fb916b336458234b1d2c
7
+ data.tar.gz: 2c0f26e38b5c70d3bc47d9a5ddf5d51a1b0eb3f60e8efc1fa9d642c20f95cc754b4cba1ff2203d1502c4498ea2a62daae163e6ecb43fe9e5c2233172d5bb8064
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /coverage/
11
+ /test/geocoder_test.sqlite
12
+ /test/fixtures/dump.rdb
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+
5
+ script: 'bundle exec rake'
6
+
7
+ notifications:
8
+ email:
9
+ recipients:
10
+ - ping@jaigouk.kim
11
+ on_failure: change
12
+ on_success: never
data/Gemfile ADDED
@@ -0,0 +1,45 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in geocoder-olleh.gemspec
4
+ gem 'geocoder'
5
+ group :development, :test do
6
+ gem 'mongoid', '2.6.0'
7
+ gem 'bson_ext', platforms: :ruby
8
+ gem 'geoip'
9
+ gem 'rubyzip'
10
+ gem 'rails'
11
+ gem 'test-unit' # needed for Ruby >=2.2.0
12
+ gem 'byebug', platforms: :mri
13
+ gem 'guard'
14
+ gem 'guard-test'
15
+ gem 'coveralls'
16
+ gem 'pry'
17
+ gem 'pry-remote'
18
+ gem 'pry-nav'
19
+ platforms :jruby do
20
+ gem 'jruby-openssl'
21
+ gem 'jgeoip'
22
+ end
23
+
24
+ platforms :rbx do
25
+ gem 'rubysl', '~> 2.0'
26
+ gem 'rubysl-test-unit'
27
+ end
28
+ end
29
+
30
+ group :test do
31
+ gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
32
+
33
+ platforms :ruby do
34
+ gem 'pg'
35
+ gem 'mysql2'
36
+ end
37
+
38
+ platforms :jruby do
39
+ gem 'jdbc-mysql'
40
+ gem 'jdbc-sqlite3'
41
+ gem 'activerecord-jdbcpostgresql-adapter'
42
+ end
43
+ end
44
+
45
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+
2
+ guard :test do
3
+ watch(%r{^test/.+_test\.rb$})
4
+ watch('test/test_helper.rb') { 'test' }
5
+
6
+ # Non-rails
7
+ watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jaigouk Kim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,84 @@
1
+ Geocoder Olleh
2
+ ==============
3
+
4
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/geocoder/olleh`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+
6
+ TODO: Delete this and the text above, and describe your gem
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'geocoder-olleh'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install geocoder-olleh
23
+
24
+ ## Olleh (`:olleh`)
25
+
26
+ * **API key**: required (set `Geocoder.configure(:api_key => [app_id, app_key])`)
27
+ * **Quota**: Dependant on service plan
28
+ * **Region**: South Korea
29
+ * **SSL support**: no
30
+ * **Languages**: Korean
31
+ * **Documentation**: https://www.ollehmap.com/spacedata/
32
+ * **Terms of Service**: https://www.ollehmap.com/spacedata/#이용약관
33
+ * **Limitations**: Only for commercial use. For commercial usage please check https://www.ollehmap.com/guide/
34
+
35
+ Caching
36
+ -------
37
+
38
+ It's a good idea, when relying on any external service, to cache retrieved data. When implemented correctly it improves your app's response time and stability. It's easy to cache geocoding results with Geocoder, just configure a cache store:
39
+
40
+ Geocoder.configure(:cache => Redis.new)
41
+
42
+ This example uses Redis, but the cache store can be any object that supports these methods:
43
+
44
+ * `store#[](key)` or `#get` or `#read` - retrieves a value
45
+ * `store#[]=(key, value)` or `#set` or `#write` - stores a value
46
+ * `store#del(url)` - deletes a value
47
+
48
+ Even a plain Ruby hash will work, though it's not a great choice (cleared out when app is restarted, not shared between app instances, etc).
49
+
50
+ You can also set a custom prefix to be used for cache keys:
51
+
52
+ Geocoder.configure(:cache_prefix => "...")
53
+
54
+ By default the prefix is `geocoder:`
55
+
56
+ If you need to expire cached content:
57
+
58
+ Geocoder::Lookup.get(Geocoder.config[:lookup]).cache.expire(:all) # expire cached results for current Lookup
59
+ Geocoder::Lookup.get(:google).cache.expire("http://...") # expire cached result for a specific URL
60
+ Geocoder::Lookup.get(:google).cache.expire(:all) # expire cached results for Google Lookup
61
+ # expire all cached results for all Lookups.
62
+ # Be aware that this methods spawns a new Lookup object for each Service
63
+ Geocoder::Lookup.all_services.each{|service| Geocoder::Lookup.get(service).cache.expire(:all)}
64
+
65
+ Do *not* include the prefix when passing a URL to be expired. Expiring `:all` will only expire keys with the configured prefix (won't kill every entry in your key/value store).
66
+
67
+ For an example of a cache store with URL expiry please see examples/autoexpire_cache.rb
68
+
69
+ _Before you implement caching in your app please be sure that doing so does not violate the Terms of Service for your geocoding service._
70
+
71
+
72
+ ## Development
73
+
74
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
75
+
76
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
77
+
78
+ ## Contributing
79
+
80
+ 1. Fork it ( https://github.com/[my-github-username]/geocoder-olleh/fork )
81
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
82
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
83
+ 4. Push to the branch (`git push origin my-new-feature`)
84
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,80 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ ACCEPTED_DB_VALUES = %w(sqlite postgres mysql)
5
+ DATABASE_CONFIG_FILE = 'test/database.yml'
6
+
7
+ def config
8
+ require 'yaml'
9
+ YAML.load(File.open(DATABASE_CONFIG_FILE))
10
+ end
11
+
12
+ namespace :db do
13
+ task :create do
14
+ if ACCEPTED_DB_VALUES.include? ENV['DB']
15
+ Rake::Task["db:#{ENV['DB']}:create"].invoke
16
+ end
17
+ end
18
+
19
+ task :drop do
20
+ if ACCEPTED_DB_VALUES.include? ENV['DB']
21
+ Rake::Task["db:#{ENV['DB']}:drop"].invoke
22
+ end
23
+ end
24
+
25
+ task :reset => [:drop, :create]
26
+
27
+ namespace :mysql do
28
+ desc 'Create the MySQL test databases'
29
+ task :create do
30
+ `mysql --user=#{config['mysql']['username']} -e "create DATABASE #{config['mysql']['database']} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci "`
31
+ end
32
+
33
+ desc 'Drop the MySQL test databases'
34
+ task :drop do
35
+ `mysqladmin --user=#{config['mysql']['username']} -f drop #{config['mysql']['database']}`
36
+ end
37
+ end
38
+
39
+ namespace :postgres do
40
+ desc 'Create the PostgreSQL test databases'
41
+ task :create do
42
+ `createdb -E UTF8 -T template0 #{config['postgres']['database']}`
43
+ end
44
+
45
+ desc 'Drop the PostgreSQL test databases'
46
+ task :drop do
47
+ `dropdb #{config['postgres']['database']}`
48
+ end
49
+ end
50
+
51
+ namespace :sqlite do
52
+ task :drop
53
+ task :create
54
+ end
55
+ end
56
+
57
+ require 'rake/testtask'
58
+ desc "Use DB to test with #{ACCEPTED_DB_VALUES}, otherwise test standalone"
59
+ Rake::TestTask.new(:test) do |test|
60
+ Rake::Task['db:reset'].invoke if ACCEPTED_DB_VALUES.include? ENV['DB']
61
+ test.libs << 'lib' << 'test'
62
+ test.pattern = 'test/unit/**/*_test.rb'
63
+ test.verbose = true
64
+ end
65
+
66
+ # Rake::TestTask.new(:integration) do |test|
67
+ # test.libs << 'lib' << 'test'
68
+ # test.pattern = 'test/integration/*_test.rb'
69
+ # test.verbose = true
70
+ # end
71
+
72
+ task :default => [:test]
73
+
74
+ require 'rdoc/task'
75
+ Rake::RDocTask.new do |rdoc|
76
+ rdoc.rdoc_dir = 'rdoc'
77
+ rdoc.title = "Geocoder #{Geocoder::Olleh::VERSION}"
78
+ rdoc.rdoc_files.include('*.rdoc')
79
+ rdoc.rdoc_files.include('lib/**/*.rb')
80
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "geocoder/olleh"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'date'
5
+ require 'geocoder/olleh/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "geocoder-olleh"
9
+ spec.version = Geocoder::Olleh::VERSION
10
+ spec.authors = ["Jaigouk Kim"]
11
+ spec.email = ["ping@jaigouk.kim"]
12
+
13
+ spec.summary = %q{geocoding with Olleh map api}
14
+ spec.description = %q{Provides object geocoding}
15
+ spec.homepage = "https://github.com/jaigouk/geocoder-olleh"
16
+ spec.license = "MIT"
17
+ spec.date = Date.today.to_s
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ spec.require_paths = ["lib"]
21
+ spec.add_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,62 @@
1
+ require 'geocoder'
2
+ module Geocoder
3
+ module Lookup
4
+ extend self
5
+
6
+ ##
7
+ # All street address lookup services, default first.
8
+ #
9
+ def street_services_with_olleh
10
+ @street_services_with_olleh ||= [
11
+ :dstk,
12
+ :esri,
13
+ :google,
14
+ :google_premier,
15
+ :google_places_details,
16
+ :yahoo,
17
+ :bing,
18
+ :geocoder_ca,
19
+ :geocoder_us,
20
+ :yandex,
21
+ :nominatim,
22
+ :mapquest,
23
+ :opencagedata,
24
+ :ovi,
25
+ :here,
26
+ :baidu,
27
+ :geocodio,
28
+ :smarty_streets,
29
+ :okf,
30
+ :postcode_anywhere_uk,
31
+ :olleh,
32
+ :test
33
+ ]
34
+ end
35
+
36
+ def all_services
37
+ street_services_with_olleh + ip_services
38
+ end
39
+
40
+ def get(name)
41
+ @services = {} unless defined? @services
42
+ @services[name] = spawn(name) unless @services.include?(name)
43
+ @services[name]
44
+ end
45
+
46
+ private # -----------------------------------------------------------------
47
+
48
+ ##
49
+ # Spawn a Lookup of the given name.
50
+ #
51
+ def spawn(name)
52
+ if street_services_with_olleh.include?(name)
53
+ Geocoder::Lookup.const_get(classify_name(name)).new
54
+ else
55
+ valids = street_services_with_olleh.map(&:inspect).join(", ")
56
+ raise ConfigurationError, "Please specify a valid lookup for Geocoder " +
57
+ "(#{name.inspect} is not one of: #{valids})."
58
+ end
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,230 @@
1
+ require 'geocoder'
2
+ require_relative "../../olleh"
3
+ require 'base64'
4
+ require 'uri'
5
+ require 'json'
6
+ module Geocoder::Lookup
7
+ ##
8
+ # Route Search
9
+ # shortest : ignore traffic. shortest path
10
+ # high way : include high way
11
+ # free way : no charge
12
+ # optimal : based on traffic
13
+ class Olleh < Base
14
+
15
+
16
+ PRIORITY = {
17
+ 'shortest' => 0, # 최단거리 우선
18
+ 'high_way' => 1, # 고속도로 우선
19
+ 'free_way' => 2, # 무료도로 우선
20
+ 'optimal' => 3 # 최적경로
21
+ }
22
+
23
+ ADDR_CD_TYPES = {
24
+ 'law' => 0, # 법정동
25
+ 'administration' => 1, # 행정동
26
+ 'law_and_admin' => 2,
27
+ 'road' => 3
28
+ }
29
+
30
+ NEW_ADDR_TYPES = {
31
+ 'old' => 0,
32
+ 'new' => 1
33
+ }
34
+
35
+ INCLUDE_JIBUN = {
36
+ 'no' => 0,
37
+ 'yes' => 1
38
+ }
39
+
40
+ COORD_TYPES = {
41
+ 'utmk' => 0,
42
+ 'tm_west' => 1,
43
+ 'tm_mid' => 2,
44
+ 'tm_east' => 3,
45
+ 'katec' => 4,
46
+ 'utm52' => 5,
47
+ 'utm51' => 6,
48
+ 'wgs84' => 7,
49
+ 'bessel' => 8
50
+ }
51
+
52
+ def initialize
53
+ super
54
+ Geocoder.configure(
55
+ :use_https => true,
56
+ :http_headers => {"Authorization" => "Basic #{token}"}
57
+ )
58
+ end
59
+
60
+ def name
61
+ "Olleh"
62
+ end
63
+
64
+ def required_api_key_parts
65
+ ["app_id", "app_key"]
66
+ end
67
+
68
+ def query_url(query)
69
+ base_url(query) + url_query_string(query)
70
+ end
71
+
72
+ def self.priority
73
+ PRIORITY
74
+ end
75
+
76
+ def self.addrcdtype
77
+ ADDR_CD_TYPES
78
+ end
79
+
80
+ def self.new_addr_types
81
+ NEW_ADDR_TYPES
82
+ end
83
+
84
+ def self.include_jibun
85
+ INCLUDE_JIBUN
86
+ end
87
+
88
+ def self.coord_types
89
+ COORD_TYPES
90
+ end
91
+
92
+ def auth_key
93
+ token
94
+ end
95
+
96
+
97
+ private # ----------------------------------------------
98
+
99
+ # results goes through structure and check returned hash.
100
+ def results(query)
101
+ data = fetch_data(query)
102
+ return [] unless data
103
+ doc = JSON.parse(URI.decode(data["payload"]))
104
+
105
+ if doc['ERRCD'] != 0
106
+ Geocoder.log(:warn, "Olleh API error: #{doc['ERRCD']} (#{doc['ERRMS'].gsub('+', ' ')}).")
107
+ return []
108
+ end
109
+
110
+ # GEOCODING / REVERSE GECOCODING
111
+ if doc['RESDATA']['COUNT']
112
+ return [] if doc['RESDATA']['COUNT'] == 0
113
+ return doc['RESDATA']["ADDRS"]
114
+
115
+ # ROUTE SEARCH
116
+ elsif doc["RESDATA"]["SROUTE"] && doc["RESDATA"]["SROUTE"]["isRoute"]
117
+ return [] if doc["RESDATA"]["SROUTE"]["isRoute"] == "false"
118
+ return doc["RESDATA"]
119
+ else
120
+ []
121
+ end
122
+ end
123
+
124
+
125
+
126
+ def make_api_request(query)
127
+ timeout(configuration.timeout) do
128
+ uri = URI.parse(query_url(query))
129
+ Geocoder.log(:debug, "Geocoder: HTTP request being made for #{uri.to_s}")
130
+ http_client.start(uri.host, uri.port, use_ssl: use_ssl?) do |client|
131
+ req = Net::HTTP::Get.new(uri.request_uri, configuration.http_headers)
132
+
133
+ client.request(req)
134
+ end
135
+ end
136
+ end
137
+
138
+ def token
139
+ if a = configuration.api_key
140
+ if a.is_a?(Array)
141
+ return Base64.encode64("#{a.first}:#{a.last}").strip
142
+ end
143
+ end
144
+ end
145
+
146
+ def now
147
+ Time.now.strftime("%Y%m%d%H%M%S%L")
148
+ end
149
+
150
+ def base_url(query)
151
+ case check_query_type(query)
152
+ when "route_search"
153
+ "https://openapi.kt.com/maps/etc/RouteSearch?params="
154
+ when "reverse_geocoding"
155
+ "https://openapi.kt.com/maps/geocode/GetAddrByGeocode?params="
156
+ when "convert_coord"
157
+ "https://openapi.kt.com/maps/etc/ConvertCoord?params="
158
+ else
159
+ "https://openapi.kt.com/maps/geocode/GetGeocodeByAddr?params="
160
+ end
161
+ end
162
+
163
+
164
+ def query_url_params(query)
165
+ case check_query_type(query)
166
+ when "route_search"
167
+ JSON.generate({
168
+ SX: query.options[:start_x],
169
+ SY: query.options[:start_y],
170
+ EX: query.options[:end_x],
171
+ EY: query.options[:end_y],
172
+ VX1: query.options[:vx1],
173
+ VY1: query.options[:vy1],
174
+ VX2: query.options[:vx2],
175
+ VY2: query.options[:vy2],
176
+ VX3: query.options[:vx3],
177
+ VY3: query.options[:vy3],
178
+ RPTYPE: "0",
179
+ COORDTYPE: Olleh.coord_types[query.options[:coord_type]] || 7,
180
+ PRIORITY: Olleh.priority[query.options[:priority]],
181
+ timestamp: now
182
+ })
183
+ when "convert_coord"
184
+ JSON.generate({
185
+ x: query.text.first,
186
+ y: query.text.last,
187
+ inCoordType: self.coord_types[options[:coord_in]],
188
+ outCoordType: self.coord_types[options[:coord_out]],
189
+ timestamp: now
190
+ })
191
+ when "reverse_geocoding"
192
+ JSON.generate({
193
+ x: query.text.first,
194
+ y: query.text.last,
195
+ addrcdtype: Olleh.addrcdtype[query.options[:addrcdtype]] || 0,
196
+ newAddr: Olleh.new_addr_types[query.options[:new_addr_type]] || 0,
197
+ isJibun: Olleh.include_jibun[query.options[:include_jibun]] || 0,
198
+ timestamp: now
199
+ })
200
+ else # geocoding
201
+ JSON.generate({
202
+ addr: URI.encode(query.sanitized_text),
203
+ addrcdtype: Olleh.addrcdtype[query.options[:addrcdtype]],
204
+ timestamp: now
205
+ })
206
+ end
207
+ end
208
+
209
+ def url_query_string(query)
210
+ URI.encode(
211
+ query_url_params(query)
212
+ ).gsub(':','%3A').gsub(',','%2C').gsub('https%3A', 'https:')
213
+ end
214
+
215
+ def check_query_type(query)
216
+ if !query.options.empty? && query.options.include?(:priority)
217
+ "route_search"
218
+ elsif query.reverse_geocode?
219
+ "reverse_geocoding"
220
+ elsif !query.options.empty? && query.options.include?(:coord_in)
221
+ "convert_coord"
222
+ else
223
+ "geocoding"
224
+ end
225
+ end
226
+
227
+
228
+
229
+ end
230
+ end
@@ -0,0 +1,93 @@
1
+ require 'geocoder'
2
+ require_relative "../../olleh"
3
+
4
+ module Geocoder::Result
5
+ class Olleh < Base
6
+
7
+ # NEED TO CHECK COORD SYSTEM
8
+ #
9
+ def latitude
10
+ coordinates[0].to_f
11
+ end
12
+
13
+ def longitude
14
+ coordinates[1].to_f
15
+ end
16
+
17
+ def address
18
+ @data['ADDRESS'].gsub('+', ' ')
19
+ end
20
+
21
+ def city
22
+ @data['ADDRESS'].split('+').first
23
+ end
24
+
25
+ def gu
26
+ @data['ADDRESS'].split('+')[1]
27
+ end
28
+
29
+ def dong
30
+ @data['ADDRESS'].split('+')[2]
31
+ end
32
+
33
+ def dong_code
34
+ @data['DONG_CODE']
35
+ end
36
+
37
+ alias_method :region, :country
38
+
39
+ def state_code
40
+ ""
41
+ end
42
+
43
+ alias_method :state, :state_code
44
+
45
+ def country
46
+ "South Korea"
47
+ end
48
+
49
+ alias_method :country_code, :country
50
+
51
+ def postal_code
52
+ ""
53
+ end
54
+
55
+ def coordinates
56
+ [@data['X'], @data['Y']]
57
+ end
58
+
59
+ def address_data
60
+ @data['ADDRESS']
61
+ end
62
+
63
+ def self.response_attributes
64
+ %w[bbox name confidence entityType]
65
+ end
66
+
67
+
68
+ #########
69
+ # methods for route search results
70
+ def total_time
71
+ @data[1]['ROUTE']['total_time']
72
+ end
73
+
74
+ def total_dist
75
+ @data[1]['ROUTE']['total_dist']
76
+ end
77
+
78
+ def rg_cound
79
+ @data[1]['ROUTE']['rg_count']
80
+ end
81
+
82
+ def rg_links
83
+ @data[1]['ROUTE']['rg']
84
+ end
85
+
86
+
87
+ response_attributes.each do |a|
88
+ define_method a do
89
+ @data[a]
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,5 @@
1
+ module Geocoder
2
+ module Olleh
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require_relative "./olleh/lookup"
2
+ require_relative "./olleh/version"
3
+ require_relative "./olleh/lookups/olleh"
4
+ require_relative "./olleh/results/olleh"
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geocoder-olleh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jaigouk Kim
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Provides object geocoding
42
+ email:
43
+ - ping@jaigouk.kim
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - Gemfile
51
+ - Guardfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/setup
57
+ - geocoder-olleh.gemspec
58
+ - lib/geocoder/olleh.rb
59
+ - lib/geocoder/olleh/lookup.rb
60
+ - lib/geocoder/olleh/lookups/olleh.rb
61
+ - lib/geocoder/olleh/results/olleh.rb
62
+ - lib/geocoder/olleh/version.rb
63
+ homepage: https://github.com/jaigouk/geocoder-olleh
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.6
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: geocoding with Olleh map api
87
+ test_files: []