module Geocoder::Lookup
Public Instance Methods
all_services()
click to toggle source
# File lib/geocoder/olleh/lookup.rb, line 36 def all_services street_services_with_olleh + ip_services end
base_url(query)
click to toggle source
# File lib/geocoder/lookups/olleh.rb, line 189 def base_url(query) host = "#{protocol}://api.ollehmap.com:10082" path = case Olleh.check_query_type(query) when "addr_local_search" "/ocsp/v2/search/km2_LocalSearch.json?" when "route_search" "/giop/rest/etc/RouteSearch.json?" when "reverse_geocoding" "/giop/rest/geocode/Rgeocode.json?" when "convert_coord" "/giop/rest/etc/ConvertCoord.json?" when "addr_step_search" "/ocsp/v1/search/AddrStepSearch.json?" when "addr_nearest_position_search" "/ocsp/v2/search/km2_AddrNearestPosSearch.json?" else #geocoding "/giop/rest/geocode/Geocode.json?" end host + path end
blank?(obj)
click to toggle source
# File lib/geocoder/lookups/olleh.rb, line 185 def blank?(obj) obj.nil? || obj.empty? end
cache_key(query)
click to toggle source
# File lib/geocoder/lookups/olleh.rb, line 290 def cache_key(query) Geocoder.config[:cache_prefix] + query_url(query) end
get(name)
click to toggle source
# File lib/geocoder/olleh/lookup.rb, line 40 def get(name) @services_with_olleh = {} unless defined? @services_with_olleh @services_with_olleh[name] = spawn(name) unless @services_with_olleh.include?(name) @services_with_olleh[name] end
local_search_result(result_data)
click to toggle source
# File lib/geocoder/lookups/olleh.rb, line 173 def local_search_result(result_data) if result_data["addr"] && !blank?(result_data["addr"]["Data"]) result_data["addr"]["Data"] elsif result_data["New_addrs"] && !blank?(result_data["New_addrs"]["Data"]) result_data["New_addrs"]["Data"] elsif result_data["place"] && !blank?(result_data["place"]["Data"]) result_data["place"]["Data"] else nil end end
query_url_params(query)
click to toggle source
# File lib/geocoder/lookups/olleh.rb, line 211 def query_url_params(query) case Olleh.check_query_type(query) when "addr_local_search" # option 2 is for sorting based on location of user. # we are using default. "1" # # we can add UTMK X, Y coordinates for that. # but i am not using it. it's optional. # isarea = 1 should be used in this case. # r is for setting radius. (300, 500, 1000, 2000, 40000) # # places is for number of results. 100 is the maximum. # # sr is for # isaddr for searching address only. excluding building name, etc. # s: "AN" means it will return old / new style addresses. # hash = { query: query.sanitized_text, option: "1", s: "AN", places: query.options[:places], sr: query.options[:sr], isaddr: Olleh.new_addr_search_options[query.options[:isaddr]] || "1" } when "route_search" hash = { SX: query.options[:start_x], SY: query.options[:start_y], EX: query.options[:end_x], EY: query.options[:end_y], RPTYPE: 0, COORDTYPE: Olleh.route_coord_types[query.options[:coord_type]] || 7, PRIORITY: Olleh.priority[query.options[:priority]] } (1..3).each do |x| s = [query.options[:"vx#{x}"], query.options[:"vy#{x}"]] hash.merge!({ "VX#{x}" => s[0], "VY#{x}" => s[1]}) unless s[0].nil? && s[1].nil? end when "convert_coord" hash = { x: query.text.first, y: query.text.last, inCoordType: Olleh.coord_types[query.options[:coord_in]], outCoordType: Olleh.coord_types[query.options[:coord_out]] } when "reverse_geocoding" hash = { x: query.text.first, y: query.text.last, addrcdtype: Olleh.addrcdtype[query.options[:addrcdtype]] || 0, newAddr: Olleh.new_addr_types[query.options[:new_addr_type]] || 0, isJibun: Olleh.include_jibun[query.options[:include_jibun]] || 0 } when "addr_step_search" hash = { l_Code: query.options[:l_code] } when "addr_nearest_position_search" hash = { PX: query.options[:px], PY: query.options[:py], RADIUS: query.options[:radius] } else # geocoding hash = { addr: query.sanitized_text, addrcdtype: Olleh.addrcdtype[query.options[:addrcdtype]] || 0 } end hash.merge!(key: configuration.api_key) hash end
street_services_with_olleh()
click to toggle source
All street address lookup services, default first.
# File lib/geocoder/olleh/lookup.rb, line 9 def street_services_with_olleh @street_services_with_olleh ||= [ :dstk, :esri, :google, :google_premier, :google_places_details, :yahoo, :bing, :geocoder_ca, :geocoder_us, :yandex, :nominatim, :mapquest, :opencagedata, :ovi, :here, :baidu, :geocodio, :smarty_streets, :okf, :postcode_anywhere_uk, :olleh, :test ] end
url_query_string(query)
click to toggle source
# File lib/geocoder/lookups/olleh.rb, line 286 def url_query_string(query) URI.encode_www_form(query_url_params(query)) end