google_timeline 2.1.0 → 2.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 544e2424574d2316af29b04e923bd5c2d4e5db00
4
- data.tar.gz: ee22f128d7e5abe4a46a85936055ef93f4b9121a
3
+ metadata.gz: 6addedf245f5692f7c729c0e5a3d83ce7a84d8b6
4
+ data.tar.gz: 0969009c7651109a9b1fb321a6c20f672d9e5dcf
5
5
  SHA512:
6
- metadata.gz: cd4f77e1caf5091535fb1473e253aef3ca4aaaf440ab6554ab314c53a6f4d38f27d870273e15986b2261b467468b2d49421ab4a0e2c56cafd63137bfd139188f
7
- data.tar.gz: dcc29c29aea18d262c62d0bdf4d56690a78584b5974e44983dbc29363918ccd00eea255ef2cad3f0fe463660809933df2eb2d0397591d0929007b8c67cbc91b2
6
+ metadata.gz: eae603dd7b0f8adb990b3baf3d603f403789d14bf2ada274e9ab0c0fe2aa56be9157c8b2a2a72dad8cbfcc0b140e90ac82a3f7e796b0c9da5558a81558961c85
7
+ data.tar.gz: 77e9bb7b00d3dca1e442f4a4daee3c1998df33436092dc8c18d304b4194b914dc070eedaa29f79eb80d8b5ad49dd21141fc7e663762f432cdea2abf7f9998a5b
data/Gemfile.lock CHANGED
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- google_timeline (1.0.2)
5
- nokogiri (~> 1.6)
4
+ google_timeline (2.2.0)
5
+ nokogiri (~> 1.7.2)
6
6
  polylines (~> 0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  diff-lcs (1.2.5)
12
- mini_portile2 (2.0.0)
13
- nokogiri (1.6.7.2)
14
- mini_portile2 (~> 2.0.0.rc2)
12
+ mini_portile2 (2.1.0)
13
+ nokogiri (1.7.2)
14
+ mini_portile2 (~> 2.1.0)
15
15
  polylines (0.3.0)
16
16
  rake (10.5.0)
17
17
  rspec (3.4.0)
@@ -38,4 +38,4 @@ DEPENDENCIES
38
38
  rspec (~> 3.0)
39
39
 
40
40
  BUNDLED WITH
41
- 1.11.2
41
+ 1.16.1
data/README.md CHANGED
@@ -20,24 +20,38 @@ Or install it yourself as:
20
20
  $ gem install google_timeline
21
21
 
22
22
  ## Usage
23
-
23
+ You can get the google map url by passing the KML file. i.e.
24
24
  ```ruby
25
25
  GoogleTimeline.get_timeline("/home/surajit/Downloads/history-2016-04-03.kml")
26
26
  ```
27
27
  => {:date=>#<Date: 2016-04-03 ((2457482j,0s,0n),+0s,2299161j)>, :url=>"http://maps.googleapis.com/maps/api/staticmap?scale=2&path=enc:}lvmA{f}xMVYi@GGAAAf@n@i@o@IDCKIC@?A?f@LLBFDaAYKCRFCAybCWn[vjEmXbbJk_CjhFhR`UjbGfwJrhN~cIjtJfoO~tI|{KxuIvdMz|E~~Sz[jzC~~JfpQ`zCznPljHdzSziJpyPliL|oLgfAfcJxtCnfI????tIjhDvI|wO~tC|hMsR`nAksAzhNyoAh`Im@G_@rzLweKnyMgaJb{IxvE~`G|wHztChCsq@imFy]ayEohBaDarHnwBirC??aWbS`WcS||BwvA`jLgyLhAyzGtpCaaVjSakMumDcmMbk@cxMshCa{MxuAcrIc|@avF}nD}fDamIgpFmxJe~NszEucRczBosHgsEyxQelEg_EEj@fAeFmLybCeqB_dFk{BqvNcpGqiHwlEygEa{Fg_LezHoiKswL}zGt_Bc|FfjCahSmbBmkI_|DbK&size=600x600&sensor=false"}
28
28
 
29
- or
29
+ or, you can pass the **{:distance => true}** parameter to get the total distance covered for the day
30
30
  ```ruby
31
31
  GoogleTimeline.get_timeline("/home/surajit/Downloads/history-2016-04-03.kml", {:distance=>true})
32
32
  ```
33
33
  => {:date=>#<Date: 2016-04-03 ((2457482j,0s,0n),+0s,2299161j)>, :url=>"http://maps.googleapis.com/maps/api/staticmap?scale=2&path=enc:}lvmA{f}xMVYi@GGAAAf@n@i@o@IDCKIC@?A?f@LLBFDaAYKCRFCAybCWn[vjEmXbbJk_CjhFhR`UjbGfwJrhN~cIjtJfoO~tI|{KxuIvdMz|E~~Sz[jzC~~JfpQ`zCznPljHdzSziJpyPliL|oLgfAfcJxtCnfI????tIjhDvI|wO~tC|hMsR`nAksAzhNyoAh`Im@G_@rzLweKnyMgaJb{IxvE~`G|wHztChCsq@imFy]ayEohBaDarHnwBirC??aWbS`WcS||BwvA`jLgyLhAyzGtpCaaVjSakMumDcmMbk@cxMshCa{MxuAcrIc|@avF}nD}fDamIgpFmxJe~NszEucRczBosHgsEyxQelEg_EEj@fAeFmLybCeqB_dFk{BqvNcpGqiHwlEygEa{Fg_LezHoiKswL}zGt_Bc|FfjCahSmbBmkI_|DbK&size=600x600&sensor=false", :distance=>{:value=>520181.2852676145, :unit=>"meter"}}
34
34
 
35
- or
35
+ or, you can pass the **{:home_coordinate => [x,y]}** parameter to define your home location.
36
36
  ```ruby
37
37
  GoogleTimeline.get_timeline("/home/surajit/Downloads/history-2016-04-03.kml", {:distance=>true}, {:home_coordinate=>[0,0]})
38
38
  ```
39
39
  => {:date=>#<Date: 2016-04-03 ((2457482j,0s,0n),+0s,2299161j)>, :url=>"http://maps.googleapis.com/maps/api/staticmap?scale=2&path=enc:}lvmA{f}xMVYi@GGAAAf@n@i@o@IDCKIC@?A?f@LLBFDaAYKCRFCAybCWn[vjEmXbbJk_CjhFhR`UjbGfwJrhN~cIjtJfoO~tI|{KxuIvdMz|E~~Sz[jzC~~JfpQ`zCznPljHdzSziJpyPliL|oLgfAfcJxtCnfI????tIjhDvI|wO~tC|hMsR`nAksAzhNyoAh`Im@G_@rzLweKnyMgaJb{IxvE~`G|wHztChCsq@imFy]ayEohBaDarHnwBirC??aWbS`WcS||BwvA`jLgyLhAyzGtpCaaVjSakMumDcmMbk@cxMshCa{MxuAcrIc|@avF}nD}fDamIgpFmxJe~NszEucRczBosHgsEyxQelEg_EEj@fAeFmLybCeqB_dFk{BqvNcpGqiHwlEygEa{Fg_LezHoiKswL}zGt_Bc|FfjCahSmbBmkI_|DbK&size=600x600&sensor=false", :distance=>{:value=>520181.2852676145, :unit=>"meter"}}
40
-
40
+
41
+ or, you can pass the **{:places => true}** parameter to get all the location you travelled for the day.
42
+ ```ruby
43
+ GoogleTimeline.get_timeline("/home/surajit/Downloads/history-2016-04-03.kml", {:distance=>true}, {:home_coordinate=>[0,0]})
44
+ GoogleTimeline.get_timeline(v, {:distance=>true}, {:places=>true})
45
+ ```
46
+ => {:date=>Sun, 30 Sep 2018, :url=>"http://maps.googleapis.com/maps/api/staticmap?scale=2&path=enc:mjvmAcg}xM????bALv%5cm@hAs_@|CrBlCl@`AIrCa@HEJCzCq@nBk@vAw@%5cIxAMHBDBbBz@|Ax@bBGJWBq@?QXmB^aE??iAiNhAhN??OtD]`BWbBzAr@ZFf@FB?B@jD`@|C@~Gh@`@FtBVJ@jDd@r@JBA????????AB?@AD???Cd@NpDd@fALtAFH?`E?`DHvEHZ?zALJ@J@fCb@v@N`JfAJAtB@fCEzC[HO@iAAMLCn@xCdBvAD@dAg@JGpHoFpLyIzMuJvAgA|GaFZStLuIpCuBfNuJ??pCbCfEbFbAvFR`ArAvAL@pJ`@|CbAa@nEI|@UjC?HAHi@|A}Dd@}C`AYNo@h@ADQzBAhAzEjBB?hACzCG|Ah@?r@EdC?Ng@tEOhEUrCJJnATLBN@~B%5c~Dp@dD`@ZHjAb@H?fBB~EuC????????yEnCgA@fM|PnYpQ~p@oSbyDeXnJ_]fx@kJ|_Anx@vAs@bCeA`B_AvDtBzExKdB~Dzc@cR`a@qVniJgjEdf@hWlgBpcBwHzC????????_uAeaBsiDxwAwnFzqA{]bVid@bY_GyP}E}J{z@oe@g}@w[aUl]svAp`@mvBfKaTpVG???A?????????u@L{KpBIAG?C?A?eBCoFW{@?g@BqCFU@cFFwIJgEt@IBo@FC@eBZ}FhA}Gw@o@I{Cc@O?kDK}@Ci@GGAOCGAa@AYCG?aCW}Co@kBqCC_AOaBKAG?iEo@mDWkAgBDs@HuA@AeBgAsGwA}Ey@m@I_BmAGKeDsE_BsBwBaBoAw@k@[MGgDoByC}@oBe@oA]IAIAICICGCwBk@eAe@pA}@h@a@tAeAJKhDqCeCv@mA|@kB~AGDOP?AAAC@?@SLmDJgAyAiC?YAo@BEDCGiC@yAIFNcBGIAG@gFo@oDw@i@Qs@IM?iEM_DIkDGQ?aCCK?cE[kDg@_Fu@oASyDa@KAK?wLo@yCa@SAUGAAPoBb@_Cx@oB????????a@Lwp@lZ{H`OkRnEwp@cIet@YqGOnEb@????????iE?wR?eVPgFdwA{ElWya@|Fs`@x^wFxDeVpSsTbYc`BcAox@xw@r@V????????RiE}FoHiEw@gETi@xG????????zA@tCiHuN`ZeKyBwY_G_Cb@gArB??zCvM{CwM??UrCe@jCyA~D????????rDsMtCqCJ}@tFem@????fNyGHN????????MShHxOg@hGOj@lLpFjl@xQdJpV|l@xEn_AgDvc@sJb[mLvN_IlXeP`QyEj`@aU`i@eW|q@ua@p@{Z|Ey`@~Tg]dS}k@?a@????&size=600x600&sensor=false", :distance=>{:value=>86940.98791306592, :unit=>"meter"}, :places=>["Home", "Sai Meadows", "Vijay Krishna Mansion", "Muthayala Maduvu", "WhitePearl ವೈಟ್ ಪರ್ಲ್", "Foradian", "Garuda Mall", "CENTRAL", "Tasker Town", "Max Fashion", "Mani's Dum Biryani", "Home"]}
47
+
48
+ or, you can pass the **{:transport_mode => true}** parameter to get all the Transport Mode you used for the day.
49
+ ```ruby
50
+ GoogleTimeline.get_timeline("/home/surajit/Downloads/history-2016-04-03.kml", {:distance=>true}, {:home_coordinate=>[0,0]})
51
+ GoogleTimeline.get_timeline(v, {:distance=>true}, {:places=>true}, {:transport_mode=>true})
52
+ ```
53
+ => {:date=>Sun, 30 Sep 2018, :url=>"http://maps.googleapis.com/maps/api/staticmap?scale=2&path=enc:mjvmAcg}xM????bALv%5cm@hAs_@|CrBlCl@`AIrCa@HEJCzCq@nBk@vAw@%5cIx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ZeKyBwY_G_Cb@gArB??zCvM{CwM??UrCe@jCyA~D????????rDsMtCqCJ}@tFem@????fNyGHN????????MShHxOg@hGOj@lLpFjl@xQdJpV|l@xEn_AgDvc@sJb[mLvN_IlXeP`QyEj`@aU`i@eW|q@ua@p@{Z|Ey`@~Tg]dS}k@?a@????&size=600x600&sensor=false", :distance=>{:value=>86940.98791306592, :unit=>"meter"}, *:transport_mode=>{"Driving"=>67675, "Motorcycling"=>4157, "Walking"=>2216, "Moving"=>11810}*, :places=>["Home", "Sai Meadows", "Vijay Krishna Mansion", "Muthayala Maduvu", "WhitePearl ವೈಟ್ ಪರ್ಲ್", "Foradian", "Garuda Mall", "CENTRAL", "Tasker Town", "Max Fashion", "Mani's Dum Biryani", "Home"]}
54
+
41
55
  distance and home_coordinate are optional.
42
56
  distance: To measure the travel distance which will return value in meter
43
57
  home_coordinate: to mention the home coordinate
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ["lib"]
30
30
 
31
31
  spec.add_dependency 'polylines', '~> 0'
32
- spec.add_dependency 'nokogiri', '~> 1.6'
32
+ spec.add_runtime_dependency 'nokogiri', '~> 1.7', '>= 1.7.2'
33
33
 
34
34
  spec.add_development_dependency "bundler", "~> 1.10"
35
35
  spec.add_development_dependency "rake", "~> 10.0"
@@ -8,6 +8,16 @@ class GoogleMapTimeline
8
8
  end
9
9
 
10
10
  def get_timeline_url(args)
11
+ #initialize flags
12
+ overall_distance_flag = false
13
+ transport_mode_flag = false
14
+ places_flag = false
15
+ if (args.empty?)==false
16
+ overall_distance_flag = !args.select{|a| a.is_a?(Hash) and a[:distance]==true}.first.nil?
17
+ transport_mode_flag = !args.select{|a| a.is_a?(Hash) and a[:transport_mode]==true}.first.nil?
18
+ places_flag = !args.select{|a| a.is_a?(Hash) and a[:places]==true}.first.nil?
19
+ end
20
+
11
21
  op_hash = {}
12
22
  url=default_map
13
23
  coordinates = []
@@ -34,11 +44,19 @@ class GoogleMapTimeline
34
44
 
35
45
  end
36
46
  op_hash[:url] = url
37
-
38
- if (args.empty?)==false and (args.select{|a| a.is_a?(Hash) and a[:distance]==true}.first).nil? == false
47
+ #overall distance
48
+ if overall_distance_flag
39
49
  distance = {:value => overall_distance(coordinates), :unit=>"meter"}
40
50
  op_hash[:distance] = distance
41
51
  end
52
+ #Transport Mode and places
53
+
54
+
55
+ if (transport_mode_flag or places_flag)
56
+ transport_mode_hash, places_array = transport_mode_and_places(doc, transport_mode_flag, places_flag)
57
+ op_hash[:transport_mode] = transport_mode_hash if transport_mode_flag
58
+ op_hash[:places] = places_array if places_flag
59
+ end
42
60
  return op_hash
43
61
  end
44
62
 
@@ -86,5 +104,16 @@ class GoogleMapTimeline
86
104
 
87
105
  rm * c # Delta in meters
88
106
  end
89
-
107
+
108
+ def transport_mode_and_places(doc, transport_mode_flag, places_flag)
109
+ transport_mode_hash = {}
110
+ places_array = []
111
+ if transport_mode_flag
112
+ doc.search('Placemark').select{|dc| dc.children.map(&:name).include?("LineString")}.map{|dc| dc.children.select{|d| d.name=="ExtendedData"}[0].children.map{|d| d.children[0]}.flatten[1..2].map{|d| d.children[0].text}}.each do |tm|
113
+ transport_mode_hash[tm[0]] = transport_mode_hash[tm[0]].to_i + tm[1].to_i
114
+ end
115
+ end
116
+ places_array = (doc.search('Placemark').select{|dc| dc.children.map(&:name).include?("Point")}.map{|dc| dc.children.select{|d| d.name=="name"}[0].children[0].text} rescue []) if places_flag
117
+ return transport_mode_hash, places_array
118
+ end
90
119
  end
@@ -1,3 +1,3 @@
1
1
  module GoogleTimeline
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_timeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Surajit Khan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-06 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: polylines
@@ -30,14 +30,20 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.6'
33
+ version: '1.7'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.7.2
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
- version: '1.6'
43
+ version: '1.7'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.7.2
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement