osmn 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +36 -8
- data/lib/osmn/structs.rb +3 -1
- data/lib/osmn/version.rb +1 -1
- data/test/test_osmn.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# OSMN
|
1
|
+
# OSMN [](https://codeclimate.com/github/kalmbach/osmn)
|
2
|
+
|
2
3
|
A Ruby wrapper for the OpenStreetMap Nominatim API.
|
3
4
|
|
4
5
|
> Nominatim is a tool to search osm data by name and address
|
@@ -12,7 +13,7 @@ API Details can be found at http://wiki.openstreetmap.org/wiki/Nominatim
|
|
12
13
|
$ gem install osmn
|
13
14
|
|
14
15
|
## Usage
|
15
|
-
The easy way:
|
16
|
+
### The easy way:
|
16
17
|
```ruby
|
17
18
|
# search for a place
|
18
19
|
OSMN::search('135 pilkington avenue, birmingham')
|
@@ -20,22 +21,37 @@ OSMN::search('135 pilkington avenue, birmingham')
|
|
20
21
|
# convert latitude and longitude into a place
|
21
22
|
OSMN::reverse_geocode(52.5487429714954, -1.81602098644987)
|
22
23
|
```
|
23
|
-
The full control way:
|
24
|
+
### The full control way:
|
25
|
+
#### Search
|
24
26
|
```ruby
|
25
27
|
# search for address
|
26
|
-
|
28
|
+
# required params: q (the query)
|
29
|
+
search = OSMN::Search.new(:q => '135 pilkington avenue, birmingham')
|
27
30
|
search.params = {:limit => 1}
|
28
31
|
|
29
32
|
# you can revise the params used
|
30
33
|
search.params
|
31
|
-
# >> {:
|
34
|
+
# >> {:q => '135 pilkington avenue, birmingham', :limit => 1}
|
32
35
|
|
33
36
|
# and if all is ok, you can execute the query
|
34
37
|
search.search
|
35
38
|
```
|
36
|
-
|
39
|
+
You can set any parameter defined in the Nominatim wiki page (http://wiki.openstreetmap.org/wiki/Nominatim#Parameters)
|
40
|
+
```ruby
|
41
|
+
# example parameters
|
42
|
+
params = {
|
43
|
+
:q => '135 pilkington avenue, birmingham',
|
44
|
+
:'accept-language' >= 'en',
|
45
|
+
:countrycodes => 'gb',
|
46
|
+
:bounded => 1,
|
47
|
+
:polygon => 1,
|
48
|
+
:addressdetails => 1
|
49
|
+
}
|
50
|
+
```
|
51
|
+
#### Reverse Geocode
|
37
52
|
```ruby
|
38
53
|
# convert lat and long
|
54
|
+
# required params: lat, lon (latitude and longitude)
|
39
55
|
search = OSMN::Reverse.new(:lat => 52.5487429714954)
|
40
56
|
search.params = {:lon => -1.81602098644987}
|
41
57
|
|
@@ -46,8 +62,20 @@ search.params
|
|
46
62
|
# run the query
|
47
63
|
search.reverse_geocode
|
48
64
|
```
|
65
|
+
You can set any parameter defined in the Nominatim wiki page (http://wiki.openstreetmap.org/wiki/Nominatim#Parameters_2)
|
66
|
+
```ruby
|
67
|
+
# example parameters
|
68
|
+
params = {
|
69
|
+
:lat => 52.5487429714954,
|
70
|
+
:lon => -1.81602098644987,
|
71
|
+
:'accept-language' => 'en',
|
72
|
+
:osm_type => 'W',
|
73
|
+
:zoom => 18,
|
74
|
+
:addressdetails => 1
|
75
|
+
}
|
76
|
+
```
|
49
77
|
|
50
|
-
Check the
|
78
|
+
Check the complete list of parameters for each query on the Nominatim Wiki page (http://wiki.openstreetmap.org/wiki/Nominatim)
|
51
79
|
|
52
80
|
## License
|
53
81
|
Copyright (c) 2012, Jorge Kalmbach <kalmbach.at.gmail.com>
|
@@ -72,4 +100,4 @@ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
|
72
100
|
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
73
101
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
74
102
|
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
75
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
103
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/osmn/structs.rb
CHANGED
data/lib/osmn/version.rb
CHANGED
data/test/test_osmn.rb
CHANGED
@@ -27,7 +27,7 @@ class Tests < Test::Unit::TestCase
|
|
27
27
|
assert_equal('62762024', response.place_id)
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def test_search_with_no_details
|
31
31
|
response = OSMN::search('135 pilkington avenue, birmingham', 0)[0]
|
32
32
|
|
33
33
|
assert_respond_to(response, :place_id)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osmn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.8.
|
82
|
+
rubygems_version: 1.8.23
|
83
83
|
signing_key:
|
84
84
|
specification_version: 3
|
85
85
|
summary: A Ruby wrapper for the OpenStreetMap Nominatim API.
|