underpass 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/underpass.rb +2 -2
- data/lib/underpass/ql/bounding_box.rb +1 -1
- data/lib/underpass/ql/parser.rb +2 -2
- data/lib/underpass/ql/ql.rb +1 -1
- data/lib/underpass/ql/query.rb +4 -1
- data/lib/underpass/ql/request.rb +2 -1
- data/lib/underpass/ql/shape.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 499389ab42025a727e89c1bfbee99f0444fb7db0593c06ad2959eda87d794d65
|
4
|
+
data.tar.gz: c8d700d784d837474e6fa5dd5f8d35339b8bf17cf08de41cdfa32807f87cf889
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 321f52730a7c02f9828cf5451e4a92507fb32b219114a3d1b20c93956e19e710218594a5afee47370e4cafc7e37f5226c21db8f43806ff9fc2fe7becb2ac6e5f
|
7
|
+
data.tar.gz: aeeda5fbdf1f1a355a4ee4e9d5484aaf1d71994ba3c6f08d236fc4e4473363c94fabe219a3205a8d8220f74f2ad0cc5ae45198b532e4c0f8516e5ae8f9a69e7b
|
data/lib/underpass.rb
CHANGED
@@ -5,8 +5,8 @@ require 'json'
|
|
5
5
|
|
6
6
|
require 'underpass/ql/ql'
|
7
7
|
|
8
|
-
#
|
9
|
-
#
|
8
|
+
# Underpass is a library that makes it easy to query the Overpass API
|
9
|
+
# and translate its responses into RGeo objects
|
10
10
|
module Underpass
|
11
11
|
end
|
12
12
|
|
@@ -4,7 +4,7 @@ module Underpass
|
|
4
4
|
module QL
|
5
5
|
# Bounding box related utilities.
|
6
6
|
class BoundingBox
|
7
|
-
#
|
7
|
+
# Returns the Overpass query language bounding box string
|
8
8
|
# when provided with an RGeo geometry
|
9
9
|
def self.from_geometry(geometry)
|
10
10
|
r_bb = RGeo::Cartesian::BoundingBox.create_from_geometry(geometry)
|
data/lib/underpass/ql/parser.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module Underpass
|
4
4
|
module QL
|
5
|
-
#
|
6
|
-
# which are then returned as matches
|
5
|
+
# Deals with parsing the API request response into easily digestable objects
|
6
|
+
# which are then returned as matches
|
7
7
|
class Parser
|
8
8
|
def initialize(response)
|
9
9
|
@response = response
|
data/lib/underpass/ql/ql.rb
CHANGED
@@ -9,7 +9,7 @@ require 'underpass/ql/query'
|
|
9
9
|
module Underpass
|
10
10
|
# Provides the means to work with Overpass by using the
|
11
11
|
# Overpass Query Language (QL). Overpass also provides an XML based
|
12
|
-
# query language but we're not interested in that
|
12
|
+
# query language but we're not interested in that
|
13
13
|
module QL
|
14
14
|
end
|
15
15
|
end
|
data/lib/underpass/ql/query.rb
CHANGED
@@ -2,8 +2,11 @@
|
|
2
2
|
|
3
3
|
module Underpass
|
4
4
|
module QL
|
5
|
-
#
|
5
|
+
# Provides a shortcut method that makes it easy to work with the library
|
6
6
|
class Query
|
7
|
+
# Shortcut method that glues together the whole library.
|
8
|
+
# * +bounding_box+ an RGeo polygon
|
9
|
+
# * +query+ is the Overpass QL query
|
7
10
|
def self.perform(bounding_box, query)
|
8
11
|
op_bbox = Underpass::QL::BoundingBox.from_geometry(bounding_box)
|
9
12
|
response = Underpass::QL::Request.new(query, op_bbox).run
|
data/lib/underpass/ql/request.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Underpass
|
4
4
|
module QL
|
5
|
-
# Deals with performing the Overpass API request
|
5
|
+
# Deals with performing the Overpass API request
|
6
6
|
class Request
|
7
7
|
API_URI = 'https://overpass-api.de/api/interpreter'.freeze
|
8
8
|
QUERY_TEMPLATE = <<-TEMPLATE.freeze
|
@@ -20,6 +20,7 @@ module Underpass
|
|
20
20
|
@global_bbox ||= "[#{bbox}]"
|
21
21
|
end
|
22
22
|
|
23
|
+
# Performs the API request
|
23
24
|
def run
|
24
25
|
query = QUERY_TEMPLATE.sub('BBOX', @global_bbox)
|
25
26
|
.sub('QUERY', @overpass_query)
|
data/lib/underpass/ql/shape.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
module Underpass
|
4
4
|
module QL
|
5
|
-
# Contains factories for various shapes from ways and nodes
|
5
|
+
# Contains factories for various RGeo shapes from ways and nodes parsed
|
6
|
+
# with the Parser class
|
6
7
|
class Shape
|
7
8
|
def self.polygon_from_way(way, nodes)
|
8
9
|
f = RGeo::Geographic.spherical_factory(srid: 4326)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: underpass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janos Rusiczki
|
@@ -80,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 2.
|
83
|
+
version: 2.3.0
|
84
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - ">="
|