overpass-api-ruby 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +14 -2
- data/lib/base.rb +0 -1
- data/lib/overpass_api_ruby.rb +1 -0
- data/lib/ql.rb +6 -0
- data/lib/version.rb +1 -1
- data/lib/xml.rb +8 -2
- data/spec/integration/ql_spec.rb +2 -1
- data/spec/integration/xml_spec.rb +2 -1
- data/spec/unit/base_spec.rb +1 -3
- data/spec/unit/xml_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2091fa63150f111ab3fe5c3aae154971a5ad0574
|
4
|
+
data.tar.gz: 5c202dc9277040b0d4daa2b572d01b195d597362
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b55bc705c1a9ea9d0cc822441bd04196f7c74d3f5d2353e37fadb5e0ff557b615e256dfa88dbf21f613851be044fa006fe27cfeb1c5a53c2ea1e78f2018ff79
|
7
|
+
data.tar.gz: 125738c5d7bd1f9cbc1bd01b4866d656d452e42be62dc7e8bbcefcd4568d3845f54bfbff800d13e7eaa80672fb5cbead190395eab07bda1e8b32f61e60250bb8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -23,7 +23,7 @@ require 'overpass_api_ruby'
|
|
23
23
|
options={:bbox => {:s => -34.705448, :n => -34.526562,
|
24
24
|
:w => -58.531471, :e => -58.335159},
|
25
25
|
:timeout => 900,
|
26
|
-
:
|
26
|
+
:element_limit => 1073741824}
|
27
27
|
|
28
28
|
overpass = OverpassAPI::XML.new(options)
|
29
29
|
|
@@ -50,15 +50,27 @@ query = "rel['route'='subway'];(._;>;);out body;"
|
|
50
50
|
response = overpass.query(query)
|
51
51
|
```
|
52
52
|
|
53
|
-
|
53
|
+
Common options on instantiation
|
54
54
|
------------------------
|
55
55
|
```
|
56
56
|
bbox Hash. Global bounding box.
|
57
57
|
endpoint String.
|
58
58
|
Defaults to http://overpass-api.de/api/interpreter
|
59
59
|
timeout Integer.
|
60
|
+
```
|
61
|
+
|
62
|
+
Specific options on instantiation
|
63
|
+
------------------------
|
64
|
+
QL
|
65
|
+
```
|
60
66
|
maxsize Integer.
|
61
67
|
```
|
68
|
+
|
69
|
+
XML
|
70
|
+
```
|
71
|
+
element_limit Integer.
|
72
|
+
```
|
73
|
+
|
62
74
|
See [Overpass API](http://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide)
|
63
75
|
|
64
76
|
Public methods
|
data/lib/base.rb
CHANGED
data/lib/overpass_api_ruby.rb
CHANGED
data/lib/ql.rb
CHANGED
data/lib/version.rb
CHANGED
data/lib/xml.rb
CHANGED
@@ -2,11 +2,17 @@ require_relative 'base'
|
|
2
2
|
|
3
3
|
module OverpassAPI
|
4
4
|
class XML < Base
|
5
|
+
def initialize(args={})
|
6
|
+
super
|
7
|
+
|
8
|
+
@element_limit = args[:element_limit]
|
9
|
+
end
|
10
|
+
|
5
11
|
def build_query(q)
|
6
12
|
bbox = @bbox ? "bbox='#{@bbox}'" : ''
|
7
13
|
timeout = @timeout ? "timeout='#{@timeout}'" : ''
|
8
|
-
|
9
|
-
"<osm-script #{bbox} #{timeout} #{
|
14
|
+
element_limit = @element_limit ? "element-limit='#{@element_limit}'" : ''
|
15
|
+
"<osm-script #{bbox} #{timeout} #{element_limit} output='json'>#{q}<print/></osm-script>"
|
10
16
|
end
|
11
17
|
end
|
12
18
|
end
|
data/spec/integration/ql_spec.rb
CHANGED
@@ -5,7 +5,8 @@ describe OverpassAPI::QL do
|
|
5
5
|
it "should return the right elements" do
|
6
6
|
options={:bbox => {:s => -34.705448, :n => -34.526562,
|
7
7
|
:w => -58.531471, :e => -58.335159},
|
8
|
-
:timeout => 900
|
8
|
+
:timeout => 900,
|
9
|
+
:maxsize => 10000}
|
9
10
|
|
10
11
|
overpass = OverpassAPI::QL.new(options)
|
11
12
|
|
@@ -5,7 +5,8 @@ describe OverpassAPI::XML do
|
|
5
5
|
it "should return the requested elements" do
|
6
6
|
options={:bbox => {:s => -34.705448, :n => -34.526562,
|
7
7
|
:w => -58.531471, :e => -58.335159},
|
8
|
-
:timeout => 900
|
8
|
+
:timeout => 900,
|
9
|
+
:element_limit => 100000}
|
9
10
|
|
10
11
|
overpass = OverpassAPI::XML.new(options)
|
11
12
|
|
data/spec/unit/base_spec.rb
CHANGED
@@ -12,15 +12,13 @@ describe OverpassAPI::Base do
|
|
12
12
|
it "should set the right args" do
|
13
13
|
opts = {bbox: {s: 1, n: 2, w: 3, e: 4},
|
14
14
|
endpoint: "a.endpoint.com",
|
15
|
-
timeout: 1000
|
16
|
-
maxsize: 333}
|
15
|
+
timeout: 1000}
|
17
16
|
|
18
17
|
base = OverpassAPI::Base.new(opts)
|
19
18
|
|
20
19
|
expect(base.instance_variable_get("@bbox")).to eq "1,3,2,4"
|
21
20
|
expect(base.instance_variable_get("@endpoint")).to eq "a.endpoint.com"
|
22
21
|
expect(base.instance_variable_get("@timeout")).to eq 1000
|
23
|
-
expect(base.instance_variable_get("@maxsize")).to eq 333
|
24
22
|
end
|
25
23
|
|
26
24
|
it "should set the bounding box" do
|
data/spec/unit/xml_spec.rb
CHANGED
@@ -12,12 +12,12 @@ describe OverpassAPI::XML do
|
|
12
12
|
it "should set the right opts" do
|
13
13
|
opts = {bbox: {s: 1, n: 2, w: 3, e: 4},
|
14
14
|
timeout: 1000,
|
15
|
-
|
15
|
+
element_limit: 333}
|
16
16
|
|
17
17
|
overpass = OverpassAPI::XML.new(opts)
|
18
18
|
built_query = overpass.build_query("a query")
|
19
19
|
|
20
|
-
expected_built_query = "<osm-script bbox='1,3,2,4' timeout='1000'
|
20
|
+
expected_built_query = "<osm-script bbox='1,3,2,4' timeout='1000' element-limit='333' output='json'>" <<
|
21
21
|
"a query<print/></osm-script>"
|
22
22
|
expect(built_query).to eq expected_built_query
|
23
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: overpass-api-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Salerno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpi
|