Class: Nominatim::Search
- Includes:
- Enumerable
- Defined in:
- lib/nominatim/search.rb
Instance Attribute Summary collapse
-
#criteria ⇒ Object
readonly
Returns the value of attribute criteria.
Instance Method Summary collapse
-
#address_details(bool) ⇒ Nominatim::Search
Include a breakdown of the address into elements.
-
#bounded(bool) ⇒ Nominatim::Search
Restrict the results to only items contained with the bounding box.
-
#city(city) ⇒ Nominatim::Search
City string to search for.
-
#country(country) ⇒ Nominatim::Search
Country string to search for.
-
#country_codes(codes) ⇒ Nominatim::Search
Limit search results to a specific country (or a list of countries).
-
#county(county) ⇒ Nominatim::Search
County string to search for.
-
#each(&block) ⇒ Object
Iterates over the search results.
-
#exclude_place_ids(ids) ⇒ Nominatim::Search
Exclude given place ids from the search result.
-
#featuretype(type) ⇒ Nominatim::Search
Limit results to certain type, instead of trying to match all possible matches.
-
#initialize ⇒ Search
constructor
A new instance of Search.
-
#limit(limit) ⇒ Nominatim::Search
Limit the number of returned results.
-
#polygon(bool) ⇒ Nominatim::Search
Output polygon outlines for items found.
-
#postalcode(postalcode) ⇒ Nominatim::Search
Postal code string to search for.
-
#query(q) ⇒ Nominatim::Search
Query string to search for.
-
#state(state) ⇒ Nominatim::Search
State string to search for.
-
#street(street) ⇒ Nominatim::Search
Street string to search for.
-
#viewbox(viewbox) ⇒ Nominatim::Search
The preferred area to find search results.
Methods inherited from Client
Constructor Details
#initialize ⇒ Search
Returns a new instance of Search.
6 7 8 |
# File 'lib/nominatim/search.rb', line 6 def initialize @criteria = {} end |
Instance Attribute Details
#criteria ⇒ Object (readonly)
Returns the value of attribute criteria.
4 5 6 |
# File 'lib/nominatim/search.rb', line 4 def criteria @criteria end |
Instance Method Details
#address_details(bool) ⇒ Nominatim::Search
Include a breakdown of the address into elements.
125 126 127 128 |
# File 'lib/nominatim/search.rb', line 125 def address_details(bool) @criteria[:addressdetails] = bool ? 1 : 0 self end |
#bounded(bool) ⇒ Nominatim::Search
Restrict the results to only items contained with the bounding box.
107 108 109 110 |
# File 'lib/nominatim/search.rb', line 107 def bounded(bool) @criteria[:bounded] = bool ? 1 : 0 self end |
#city(city) ⇒ Nominatim::Search
City string to search for.
38 39 40 41 |
# File 'lib/nominatim/search.rb', line 38 def city(city) @criteria[:city] = city self end |
#country(country) ⇒ Nominatim::Search
Country string to search for.
65 66 67 68 |
# File 'lib/nominatim/search.rb', line 65 def country(country) @criteria[:country] = country self end |
#country_codes(codes) ⇒ Nominatim::Search
Limit search results to a specific country (or a list of countries).
84 85 86 87 88 89 90 91 |
# File 'lib/nominatim/search.rb', line 84 def country_codes(codes) if codes.instance_of? Array @criteria[:countrycodes] = codes.join(',') else @criteria[:countrycodes] = codes end self end |
#county(county) ⇒ Nominatim::Search
County string to search for.
47 48 49 50 |
# File 'lib/nominatim/search.rb', line 47 def county(county) @criteria[:county] = county self end |
#each(&block) ⇒ Object
Iterates over the search results.
11 12 13 14 |
# File 'lib/nominatim/search.rb', line 11 def each(&block) @results ||= get(Nominatim.config.search_url, @criteria).body.map! { |attrs| Nominatim::Place.new(attrs) } @results.each(&block) end |
#exclude_place_ids(ids) ⇒ Nominatim::Search
Exclude given place ids from the search result.
134 135 136 137 138 139 140 141 |
# File 'lib/nominatim/search.rb', line 134 def exclude_place_ids(ids) if ids.instance_of? Array @criteria[:exclude_place_ids] = ids.join(',') else @criteria[:exclude_place_ids] = ids end self end |
#featuretype(type) ⇒ Nominatim::Search
Limit results to certain type, instead of trying to match all possible matches.
Possible values:
-
settlement
-
country
-
city
-
state
This feature is not in official Nominatim documentation.
165 166 167 168 |
# File 'lib/nominatim/search.rb', line 165 def featuretype(type) @criteria[:featuretype] = type self end |
#limit(limit) ⇒ Nominatim::Search
Limit the number of returned results.
147 148 149 150 |
# File 'lib/nominatim/search.rb', line 147 def limit(limit) @criteria[:limit] = limit self end |
#polygon(bool) ⇒ Nominatim::Search
Output polygon outlines for items found.
116 117 118 119 |
# File 'lib/nominatim/search.rb', line 116 def polygon(bool) @criteria[:polygon] = bool ? 1 : 0 self end |
#postalcode(postalcode) ⇒ Nominatim::Search
Postal code string to search for.
74 75 76 77 |
# File 'lib/nominatim/search.rb', line 74 def postalcode(postalcode) @criteria[:postalcode] = postalcode self end |
#query(q) ⇒ Nominatim::Search
Query string to search for.
20 21 22 23 |
# File 'lib/nominatim/search.rb', line 20 def query(q) @criteria[:q] = q self end |
#state(state) ⇒ Nominatim::Search
State string to search for.
56 57 58 59 |
# File 'lib/nominatim/search.rb', line 56 def state(state) @criteria[:state] = state self end |
#street(street) ⇒ Nominatim::Search
Street string to search for.
29 30 31 32 |
# File 'lib/nominatim/search.rb', line 29 def street(street) @criteria[:street] = street self end |
#viewbox(viewbox) ⇒ Nominatim::Search
The preferred area to find search results.
97 98 99 100 |
# File 'lib/nominatim/search.rb', line 97 def viewbox(viewbox) @criteria[:viewbox] = viewbox.join(',') self end |