route 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/route.rb +38 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3a24d7462cacf128c42e49ec47b14c49fd254dd6
|
4
|
+
data.tar.gz: a62ff7409907e053db8cdd20f7eefedc59f64467
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1163fbb0be111c7bc8b93db8414511b2e25f4adb93cb9277b9d60a613ceb6f64b99a7a87070bb0d5576cb9254789bbd442b483d0effe6b95018fab4c92404a2a
|
7
|
+
data.tar.gz: d282c4131cd510997c657262a94669e98e5ac6735fe0b4b714c2f64dda457270289a6a555880c3a59cb8c57023d6d70cea0f9ad28a3917c519fc02094efa5980
|
data/lib/route.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'url'
|
3
|
+
require 'json'
|
4
|
+
class Route
|
5
|
+
def initialize(id , code)
|
6
|
+
@id = id
|
7
|
+
@code = code
|
8
|
+
end
|
9
|
+
def route( start, destination)
|
10
|
+
s = loc(start)
|
11
|
+
d = loc(destination)
|
12
|
+
url = "https://route.api.here.com/routing/7.2/calculateroute.json" + "?app_id=" + @id + "&app_code=" + @code + "&waypoint0=geo!" + s + "&waypoint1=geo!" + d + "&mode=fastest;car;traffic:disabled&metricSystem=metric"
|
13
|
+
request = Net::HTTP::get(URI(url))
|
14
|
+
res = JSON.parse(request)
|
15
|
+
dis = res["response"]["route"][0]["summary"]["distance"]
|
16
|
+
tie = res["response"]["route"][0]["summary"]["baseTime"]
|
17
|
+
km = dis/1000.0
|
18
|
+
t = ""
|
19
|
+
if tie > 3600
|
20
|
+
h = tie/3600
|
21
|
+
tie = tie%3600
|
22
|
+
t = h.to_s + ' hours :'
|
23
|
+
end
|
24
|
+
t = t + (tie/60).to_s + ' minutes :' + (tie%60).to_s + " seconds"
|
25
|
+
return km.to_s, t
|
26
|
+
end
|
27
|
+
|
28
|
+
def loc(search)
|
29
|
+
url = "https://geocoder.api.here.com/6.2/geocode.json" + "?app_id=" + @id + "&app_code=" + @code + "&searchtext=" + search
|
30
|
+
request = Net::HTTP::get(URI(url))
|
31
|
+
res = JSON.parse(request)
|
32
|
+
lat = res["Response"]["View"][0]["Result"][0]["Location"]["NavigationPosition"][0]["Latitude"]
|
33
|
+
log = res["Response"]["View"][0]["Result"][0]["Location"]["NavigationPosition"][0]["Longitude"]
|
34
|
+
r = lat.to_s + "," + log.to_s
|
35
|
+
return r
|
36
|
+
end
|
37
|
+
private :loc
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: route
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Punith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |-
|
14
|
+
returns true if the given number is even,
|
15
|
+
otherwise returns false.
|
16
|
+
email: punithpreddy1994@email.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/route.rb
|
22
|
+
homepage: http://rubygems.org/gems/pricecalculator
|
23
|
+
licenses: []
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.6.8
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: verifies if a given number is even.
|
45
|
+
test_files: []
|