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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 869f0f15d223e2dba7f50b5aee38f229afecff1f
4
- data.tar.gz: a51e2aa6cfc9c4cd9eb9ace840d9c48eabbbacb1
3
+ metadata.gz: 2091fa63150f111ab3fe5c3aae154971a5ad0574
4
+ data.tar.gz: 5c202dc9277040b0d4daa2b572d01b195d597362
5
5
  SHA512:
6
- metadata.gz: dd3a55ea3765c2c07b842a420eae89edbcd3111338e4ad9b878a2f42b39a6de0cebb92bc4d3749d1303ffd96e351a6c9571e7ff0bf53781a60c7d733400acacb
7
- data.tar.gz: 63ea5915cbd930c273759d3da28bd87a868b57af31e6aa5af2f9ecf23fe0fa5734b43391f1cd20836b06bb30af762a069748df96d0ab10211ea8010bb0565e94
6
+ metadata.gz: 2b55bc705c1a9ea9d0cc822441bd04196f7c74d3f5d2353e37fadb5e0ff557b615e256dfa88dbf21f613851be044fa006fe27cfeb1c5a53c2ea1e78f2018ff79
7
+ data.tar.gz: 125738c5d7bd1f9cbc1bd01b4866d656d452e42be62dc7e8bbcefcd4568d3845f54bfbff800d13e7eaa80672fb5cbead190395eab07bda1e8b32f61e60250bb8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- overpass-api-ruby (0.2)
4
+ overpass-api-ruby (0.2.2)
5
5
  httpi (~> 2.4.0)
6
6
 
7
7
  GEM
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
- :maxsize => 1073741824}
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
- Options on instantiation
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
@@ -12,7 +12,6 @@ module OverpassAPI
12
12
 
13
13
  @endpoint = args[:endpoint] || DEFAULT_ENDPOINT
14
14
  @timeout = args[:timeout]
15
- @maxsize = args[:maxsize]
16
15
  end
17
16
 
18
17
  def bounding_box(s,n,w,e)
@@ -1,2 +1,3 @@
1
+ require_relative "version"
1
2
  require_relative "xml"
2
3
  require_relative "ql"
data/lib/ql.rb CHANGED
@@ -2,6 +2,12 @@ require_relative "base"
2
2
 
3
3
  module OverpassAPI
4
4
  class QL < Base
5
+ def initialize(args={})
6
+ super
7
+
8
+ @maxsize = args[:maxsize]
9
+ end
10
+
5
11
  def build_query(q)
6
12
  header = ""
7
13
  header << "[bbox:#{@bbox}]" if @bbox
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OverpassAPI
2
- VERSION='0.2.1'
2
+ VERSION='0.2.2'
3
3
  end
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
- maxsize = @maxsize ? "maxsize='#{@maxsize}'" : ''
9
- "<osm-script #{bbox} #{timeout} #{maxsize} output='json'>#{q}<print/></osm-script>"
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
@@ -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
 
@@ -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
@@ -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
- maxsize: 333}
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' maxsize='333' output='json'>" <<
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.1
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-20 00:00:00.000000000 Z
11
+ date: 2017-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpi