nmea_parser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c8747a88bf7c3b477714630d3551dbaeb5c7e483
4
+ data.tar.gz: ac5a138fe6dbd3f0ae1b8e6408aaf3388ca18cc9
5
+ SHA512:
6
+ metadata.gz: e5f52ea72b8a40dcaf3cd6740544474e517e98e14d0cfa9d9ab117cd5fe4944537caf68bda5b46469ad7cbae46da4f120711577c5555dd614c8fb4b25e2eded8
7
+ data.tar.gz: 3e50c3721bdcf9dd380726461463503ffd5b596b560971fa806536e08a508f5eaef1848e2a3dbf12faaeaaec9ef4aef826d3e8368fb8a3c12aa1acf7fdd3182b
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ file: nmea_parser.rb
4
+
5
+ require 'time'
6
+
7
+ class NMEAParser
8
+
9
+
10
+ attr_reader :longitude, :latitude, :time
11
+
12
+ def initialize(s)
13
+ parse(s)
14
+ end
15
+
16
+ def to_h()
17
+ {time: @time, latitude: @latitude, longitude: @longitude}
18
+ end
19
+
20
+ private
21
+
22
+ def parse(raw_line)
23
+
24
+ msgcode = raw_line[/^\$GP(\w+)/]
25
+ return unless msgcode
26
+
27
+ a = raw_line.split(',')
28
+
29
+ case msgcode
30
+ when /GGA/
31
+ _, raw_time, raw_lat, ns, raw_lon, ew = a
32
+ @time, @latitude, @longitude = Time.parse(raw_time),
33
+ decimalize(raw_lat, ns), decimalize(raw_lon, ew)
34
+ end
35
+
36
+ end
37
+
38
+ def decimalize(raw_x, raw_nesw)
39
+
40
+ nesw = {n: :+, e: :+, s: :-, w: :-}
41
+ x = 0.method(nesw[raw_nesw.downcase.to_sym]).call(raw_x.to_f)
42
+
43
+ degrees = (x / 100).to_i
44
+ minutes = x - (degrees * 100.0)
45
+ (degrees + (minutes / 60)).round(8)
46
+ end
47
+
48
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nmea_parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE0MDcwNTEzMzgwMVoXDTE1MDcwNTEzMzgwMVowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBALCmFMHQiV9tG4p/+Ts1nkec4hUvWB0jhSrWErpGKeMvLltNPbuSSO55uR78
19
+ 8SKN5pCIBt8AlhfhH5gndQDKdQQ/ij7brPw/g9LxuLatzGyHgQPhwExifZZUge7s
20
+ Bs/KKGlrEWgZsbW6Xa4XiMJ3SVHYi7zZyzlLparq6sdaiD0OWBqec29d31/1KZ5T
21
+ WCVCUB22EWpD99odX1D81CEFcV6ZQN1u3hqJy2Xg/9XjDtUUSLsps/8hAExeTWvu
22
+ CB6Qhz4Ar2Ap2EzikK6sExkX2El2E8qsDIWsUusj2IE+i4ZkVedE7io92891cd0z
23
+ VyFehbv1l+bXb9jCl/938sN70W8CAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUBk+4SAhr7Nca/+nvOd7swbJm8j4wJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAQ1tpRMRj
27
+ 8bvVxQN/xuwhrhEgnyKXsp/ANDPWZjyvtMZyQ56YJjlhR611c6TCJO3dzNfbmKju
28
+ 4Mjglew35ofNlsDzwWbWfINfs6rQqZeS4OIqqJuNF4UjrscXyY8G3asGpSJrt3qR
29
+ t75WEUOwmvOZ1xUfFwunpns3JhvIot/FxeHpWTLgeQhO7e9Yq4su+tg3gfjG3hWy
30
+ R85X92D3R1xx+feW11iCwkc7c24DvK4MaG9g6l+DR4o4GwHGnGnI0sNGmYi//kVs
31
+ kecA2eJrRTTEuT2J/6r156G7Jz9rSVPnBubYMAIXKbuF746TOC+jAzWRKH+916p+
32
+ xV34kKQD64O2yQ==
33
+ -----END CERTIFICATE-----
34
+ date: 2014-07-05 00:00:00.000000000 Z
35
+ dependencies: []
36
+ description:
37
+ email: james@r0bertson.co.uk
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - lib/nmea_parser.rb
43
+ homepage: https://github.com/jrobertson/nmea_parser
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.2.2
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Parses NMEA strings to fetch and convert GPS coordinates.
67
+ test_files: []
68
+ has_rdoc:
metadata.gz.sig ADDED
Binary file