geoptima 0.0.1 → 0.0.2
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.
- data/README.rdoc +4 -4
- data/examples/show_geoptima.rb +19 -2
- data/geoptima.gemspec +3 -2
- data/lib/geoptima/data.rb +34 -4
- data/lib/geoptima/version.rb +1 -1
- metadata +24 -9
data/README.rdoc
CHANGED
@@ -20,7 +20,7 @@ This script simply imports the JSON files on the command-line and then:
|
|
20
20
|
|
21
21
|
Which event types to include and various other options are available using the command-line. Run it with the -h option to get a full list of options. The current version should support:
|
22
22
|
|
23
|
-
Usage: ./
|
23
|
+
Usage: ./show_geoptima.rb <-dvxEh> <-L limit> <-E types> <-T min,max> file <files>
|
24
24
|
-d debug mode (output more context during processing) (false)
|
25
25
|
-p print mode (print out final results to console)
|
26
26
|
-v verbose mode (output extra information to console)
|
@@ -31,7 +31,7 @@ Usage: ./showGeoptimaEvents.rb <-dvxEh> <-L limit> <-E types> <-T min,max> file
|
|
31
31
|
-E comma-seperated list of event types to show and export (default: all; current: )
|
32
32
|
-T time range to limit results to (default: all; current: )
|
33
33
|
|
34
|
-
Currently the script also locates events that are close enough in time to GPS events.
|
34
|
+
Currently the script also locates events that are close enough in time to GPS events. We hope to improve this with interpolation in the near future to be more compatible with the results from the commercial solutions.
|
35
35
|
|
36
36
|
== show_geoptima_sos.rb
|
37
37
|
|
@@ -54,9 +54,9 @@ The examples directory includes a few sample Ruby scripts for various import/exp
|
|
54
54
|
|
55
55
|
git clone git@github.com:craigtaverner/geoptima.rb.git
|
56
56
|
cd geoptima.rb/examples
|
57
|
-
./
|
57
|
+
./show_geoptima.rb -x sample_geoptima.json
|
58
58
|
|
59
|
-
This should produce a file called
|
59
|
+
This should produce a file called 357841036600753.csv containing a CSV version of the Geoptima events for importing into Excel or OpenOffice.Calc for further processing. The number is the IMEI of the phone used, and if you process many JSON files in one go, you will get as many output files as there are phones represented by the data.
|
60
60
|
|
61
61
|
=== Contributing
|
62
62
|
|
data/examples/show_geoptima.rb
CHANGED
@@ -17,7 +17,7 @@ def cw(val)
|
|
17
17
|
val.nil? ? '' : "(#{val})"
|
18
18
|
end
|
19
19
|
|
20
|
-
while arg=ARGV.shift
|
20
|
+
while arg=ARGV.shift do
|
21
21
|
if arg =~ /^\-(\w+)/
|
22
22
|
$1.split(//).each do |aa|
|
23
23
|
case aa
|
@@ -33,6 +33,8 @@ while arg=ARGV.shift:
|
|
33
33
|
$export=true
|
34
34
|
when 's'
|
35
35
|
$seperate=true
|
36
|
+
when 'o'
|
37
|
+
$export_stats=true
|
36
38
|
when 'E'
|
37
39
|
$event_names += ARGV.shift.split(/[\,\;\:\.]+/)
|
38
40
|
when 'T'
|
@@ -63,6 +65,7 @@ Usage: ./showGeoptimaEvents.rb <-dvxEh> <-L limit> <-E types> <-T min,max> file
|
|
63
65
|
-p print mode (print out final results to console) #{cw $print}
|
64
66
|
-v verbose mode (output extra information to console) #{cw $verbose}
|
65
67
|
-x export IMEI specific CSV files for further processing #{cw $export}
|
68
|
+
-o export field statistis #{cw $export_stats}
|
66
69
|
-s seperate the export files by event type #{cw $seperate}
|
67
70
|
-h show this help
|
68
71
|
-L limit verbose output to specific number of lines #{cw $print_limit}
|
@@ -76,8 +79,9 @@ $verbose = $verbose || $debug
|
|
76
79
|
$datasets = Geoptima::Dataset.make_datasets($files, :locate => true, :time_range => $time_range)
|
77
80
|
|
78
81
|
class Export
|
79
|
-
attr_reader :files, :names, :headers
|
82
|
+
attr_reader :files, :imei, :names, :headers
|
80
83
|
def initialize(imei,names,dataset)
|
84
|
+
@imei = imei
|
81
85
|
@names = names
|
82
86
|
if $export
|
83
87
|
if $seperate
|
@@ -91,6 +95,7 @@ class Export
|
|
91
95
|
end
|
92
96
|
@headers = names.inject({}) do |a,name|
|
93
97
|
a[name] = dataset.header([name]).reject{|h| h === 'timeoffset'}
|
98
|
+
a[name] = a[name].map{|h| "#{name}.#{h}"} unless($separate)
|
94
99
|
puts "Created header for name #{name}: #{a[name].join(',')}" if($debug)
|
95
100
|
a
|
96
101
|
end
|
@@ -104,6 +109,17 @@ class Export
|
|
104
109
|
end
|
105
110
|
end
|
106
111
|
end
|
112
|
+
def export_stats(stats)
|
113
|
+
File.open("#{imei}_stats.csv",'w') do |out|
|
114
|
+
stats.keys.sort.each do |header|
|
115
|
+
out.puts header
|
116
|
+
values = stats[header].keys.sort
|
117
|
+
out.puts values.join("\t")
|
118
|
+
out.puts values.map{|v| stats[header][v]}.join("\t")
|
119
|
+
out.puts
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
107
123
|
def header(name=nil)
|
108
124
|
@headers[name]
|
109
125
|
end
|
@@ -146,6 +162,7 @@ $datasets.keys.sort.each do |imei|
|
|
146
162
|
names = $event_names
|
147
163
|
names = dataset.events_names if(names.length<1)
|
148
164
|
export = Export.new(imei,names,dataset)
|
165
|
+
export.export_stats(dataset.stats) if($export_stats)
|
149
166
|
events.each do |event|
|
150
167
|
names.each do |name|
|
151
168
|
if event.name === name
|
data/geoptima.gemspec
CHANGED
@@ -22,10 +22,11 @@ then rather consider the NetView and Customer IQ applications from AmanziTel at
|
|
22
22
|
EOF
|
23
23
|
|
24
24
|
s.require_path = 'lib'
|
25
|
-
s.files = Dir.glob("{bin,lib,examples}/**/*").reject{|x| x=~/(tmp|target|test-data)/} + %w(README.rdoc CHANGELOG CONTRIBUTORS Gemfile geoptima.gemspec)
|
25
|
+
s.files = Dir.glob("{bin,lib,examples}/**/*").reject{|x| x=~/(tmp|target|test-data|kurt|357|012)/} + %w(README.rdoc CHANGELOG CONTRIBUTORS Gemfile geoptima.gemspec)
|
26
26
|
s.executables = ['show_geoptima']
|
27
27
|
s.has_rdoc = true
|
28
28
|
s.extra_rdoc_files = %w( README.rdoc )
|
29
29
|
s.rdoc_options = ["--quiet", "--title", "geoptima.rb", "--opname", "index.html", "--line-numbers", "--main", "README.rdoc", "--inline-source"]
|
30
|
-
s.
|
30
|
+
s.add_dependency('json',">= 1.6.5")
|
31
|
+
s.required_ruby_version = ">= 1.8.6"
|
31
32
|
end
|
data/lib/geoptima/data.rb
CHANGED
@@ -54,7 +54,7 @@ module Geoptima
|
|
54
54
|
utc.strftime("%Y-%m-%d %H:%M:%S.%3N")
|
55
55
|
end
|
56
56
|
def [](key)
|
57
|
-
@fields[key]
|
57
|
+
@fields[key] || @fields[key.gsub(/#{name}\./,'')]
|
58
58
|
end
|
59
59
|
def -(other)
|
60
60
|
(self.time - other.time) * SPERDAY
|
@@ -81,10 +81,12 @@ module Geoptima
|
|
81
81
|
@path = path
|
82
82
|
@json = JSON.parse(File.read(path))
|
83
83
|
if $debug
|
84
|
-
puts "Read Geoptima: #{geoptima}"
|
84
|
+
puts "Read Geoptima: #{geoptima.to_json}"
|
85
85
|
puts "\tSubscriber: #{subscriber.to_json}"
|
86
86
|
puts "\tIMSI: #{imsi}"
|
87
87
|
puts "\tIMEI: #{imei}"
|
88
|
+
puts "\tMCC: #{subscriber['MCC']}"
|
89
|
+
puts "\tMNC: #{subscriber['MNC']}"
|
88
90
|
puts "\tStart: #{start}"
|
89
91
|
end
|
90
92
|
end
|
@@ -131,9 +133,14 @@ module Geoptima
|
|
131
133
|
events.keys.sort
|
132
134
|
end
|
133
135
|
def make_hash(name)
|
136
|
+
puts "About to process json hash: #{geoptima[name].to_json}" if($debug)
|
134
137
|
geoptima[name].inject({}) do |a,md|
|
135
|
-
|
136
|
-
|
138
|
+
if md.respond_to? 'keys'
|
139
|
+
key = md.keys[0]
|
140
|
+
a[key]=md[key]
|
141
|
+
else
|
142
|
+
puts "Invalid hash format for '#{name}': #{md.to_json[0..70]}..."
|
143
|
+
end
|
137
144
|
a
|
138
145
|
end
|
139
146
|
end
|
@@ -252,6 +259,28 @@ module Geoptima
|
|
252
259
|
end.flatten
|
253
260
|
end
|
254
261
|
|
262
|
+
def stats
|
263
|
+
merge_events unless @sorted
|
264
|
+
unless @stats
|
265
|
+
@stats = {}
|
266
|
+
event_count = 0
|
267
|
+
sorted.each do |event|
|
268
|
+
event_count += 1
|
269
|
+
event.header.each do |field|
|
270
|
+
key = "#{event.name}.#{field}"
|
271
|
+
value = event[field]
|
272
|
+
@stats[key] ||= {}
|
273
|
+
@stats[key][value] ||= 0
|
274
|
+
@stats[key][value] += 1
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
@stats.reject! do |k,v|
|
279
|
+
v.length > 500 || v.length > 10 && v.length > event_count / 2
|
280
|
+
end
|
281
|
+
@stats
|
282
|
+
end
|
283
|
+
|
255
284
|
def events_names
|
256
285
|
@data.map{ |v| v.events_names }.flatten.uniq.sort
|
257
286
|
end
|
@@ -280,6 +309,7 @@ module Geoptima
|
|
280
309
|
prev_gps = nil
|
281
310
|
sorted.each do |event|
|
282
311
|
if event.name === 'gps'
|
312
|
+
event.locate(event)
|
283
313
|
prev_gps = event
|
284
314
|
elsif prev_gps
|
285
315
|
event.locate_if_closer_than(prev_gps,60)
|
data/lib/geoptima/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoptima
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Craig Taverner
|
@@ -15,9 +15,24 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-
|
19
|
-
dependencies:
|
20
|
-
|
18
|
+
date: 2012-03-08 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: json
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 5
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 6
|
32
|
+
- 5
|
33
|
+
version: 1.6.5
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
21
36
|
description: |
|
22
37
|
Geoptima is a suite of applications for measuring and locating mobile/cellular subscriber experience on GPS enabled smartphones.
|
23
38
|
It is produced by AmanziTel AB in Helsingborg, Sweden, and supports many phone manufacturers, with free downloads from the
|
@@ -70,12 +85,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
85
|
requirements:
|
71
86
|
- - ">="
|
72
87
|
- !ruby/object:Gem::Version
|
73
|
-
hash:
|
88
|
+
hash: 59
|
74
89
|
segments:
|
75
90
|
- 1
|
76
91
|
- 8
|
77
|
-
-
|
78
|
-
version: 1.8.
|
92
|
+
- 6
|
93
|
+
version: 1.8.6
|
79
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
95
|
none: false
|
81
96
|
requirements:
|