Sha256: 37b92f90e9f268d059b2d42e629cb9782a4bfa12813dde9dbd0e033b22fd13e7
Contents?: true
Size: 1.46 KB
Versions: 22
Compression:
Stored size: 1.46 KB
Contents
require 'geocoder/lookups/base' require "geocoder/results/geoportail_lu" module Geocoder module Lookup class GeoportailLu < Base def name "Geoportail.lu" end def query_url(query) url_base_path(query) + url_query_string(query) end private def url_base_path(query) query.reverse_geocode? ? reverse_geocode_url_base_path : search_url_base_path end def search_url_base_path "#{protocol}://api.geoportail.lu/geocoder/search?" end def reverse_geocode_url_base_path "#{protocol}://api.geoportail.lu/geocoder/reverseGeocode?" end def query_url_geoportail_lu_params(query) query.reverse_geocode? ? reverse_geocode_params(query) : search_params(query) end def search_params(query) { queryString: query.sanitized_text } end def reverse_geocode_params(query) lat_lon = query.coordinates { lat: lat_lon.first, lon: lat_lon.last } end def query_url_params(query) query_url_geoportail_lu_params(query).merge(super) end def results(query) return [] unless doc = fetch_data(query) if doc['success'] == true result = doc['results'] else result = [] raise_error(Geocoder::Error) || warn("Geportail.lu Geocoding API error") end result end end end end
Version data entries
22 entries across 22 versions & 3 rubygems