geoptima 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/bin/show_geoptima CHANGED
@@ -24,6 +24,8 @@ $files = Geoptima::Options.process_args do |option|
24
24
  option.m {$map_headers = true}
25
25
  option.a {$combine_all = true}
26
26
  option.l {$more_headers = true}
27
+ option.e {$show_error_stats = true}
28
+ option.g {$export_gpx = true}
27
29
  option.P {$export_prefix = ARGV.shift}
28
30
  option.E {$event_names += ARGV.shift.split(/[\,\;\:\.]+/)}
29
31
  option.T {$time_range = Geoptima::DateRange.from ARGV.shift}
@@ -108,7 +110,7 @@ exit 0 if($print_version && !$verbose)
108
110
  $help = true if($files.length < 1)
109
111
  if $help
110
112
  puts <<EOHELP
111
- Usage: show_geoptima <-dwvpxomlsafh> <-P export_prefix> <-L limit> <-E types> <-T min,max> <-M mapfile> file <files>
113
+ Usage: show_geoptima <-dwvpxomlsafegh> <-P export_prefix> <-L limit> <-E types> <-T min,max> <-M mapfile> file <files>
112
114
  -d debug mode (output more context during processing) #{cw $debug}
113
115
  -w verbose mode (output extra information to console) #{cw $verbose}
114
116
  -v print geoptima library version #{Geoptima::VERSION}
@@ -120,6 +122,8 @@ Usage: show_geoptima <-dwvpxomlsafh> <-P export_prefix> <-L limit> <-E types> <-
120
122
  -s seperate the export files by event type #{cw $seperate}
121
123
  -a combine all IMEI's into a single dataset #{cw $combine_all}
122
124
  -f flush stdout #{cw $flush_stdout}
125
+ -e show error statistics #{cw $show_error_stats}
126
+ -g export GPX traces #{cw $export_gpx}
123
127
  -h show this help
124
128
  -P prefix for exported files (default: ''; current: #{$export_prefix})
125
129
  -E comma-seperated list of event types to show and export (default: all; current: #{$event_names.join(',')})
@@ -288,12 +292,21 @@ end
288
292
 
289
293
  puts "Found #{$datasets.length} datasets: #{$datasets.values.join('; ')}"
290
294
 
295
+ if $show_error_stats
296
+ $datasets.keys.sort.each do |imei|
297
+ dataset = $datasets[imei]
298
+ events = dataset.sorted # required to get the errors count
299
+ puts "Found #{dataset.errors.keys.length} errors in #{dataset.description}"
300
+ dataset.report_errors
301
+ end
302
+ end
303
+
291
304
  $datasets.keys.sort.each do |imei|
292
305
  dataset = $datasets[imei]
293
306
  imsi = dataset.imsi
294
307
  events = dataset.sorted
295
308
  puts if($print)
296
- puts "Found #{dataset.description}"
309
+ puts "Found #{dataset.description}" if($verbose || $print || $export)
297
310
  if $verbose
298
311
  puts "\tFirst Event: #{dataset.first}"
299
312
  puts "\tLast Event: #{dataset.last}"
@@ -24,6 +24,8 @@ $files = Geoptima::Options.process_args do |option|
24
24
  option.m {$map_headers = true}
25
25
  option.a {$combine_all = true}
26
26
  option.l {$more_headers = true}
27
+ option.e {$show_error_stats = true}
28
+ option.g {$export_gpx = true}
27
29
  option.P {$export_prefix = ARGV.shift}
28
30
  option.E {$event_names += ARGV.shift.split(/[\,\;\:\.]+/)}
29
31
  option.T {$time_range = Geoptima::DateRange.from ARGV.shift}
@@ -108,7 +110,7 @@ exit 0 if($print_version && !$verbose)
108
110
  $help = true if($files.length < 1)
109
111
  if $help
110
112
  puts <<EOHELP
111
- Usage: show_geoptima <-dwvpxomlsafh> <-P export_prefix> <-L limit> <-E types> <-T min,max> <-M mapfile> file <files>
113
+ Usage: show_geoptima <-dwvpxomlsafegh> <-P export_prefix> <-L limit> <-E types> <-T min,max> <-M mapfile> file <files>
112
114
  -d debug mode (output more context during processing) #{cw $debug}
113
115
  -w verbose mode (output extra information to console) #{cw $verbose}
114
116
  -v print geoptima library version #{Geoptima::VERSION}
@@ -120,6 +122,8 @@ Usage: show_geoptima <-dwvpxomlsafh> <-P export_prefix> <-L limit> <-E types> <-
120
122
  -s seperate the export files by event type #{cw $seperate}
121
123
  -a combine all IMEI's into a single dataset #{cw $combine_all}
122
124
  -f flush stdout #{cw $flush_stdout}
125
+ -e show error statistics #{cw $show_error_stats}
126
+ -g export GPX traces #{cw $export_gpx}
123
127
  -h show this help
124
128
  -P prefix for exported files (default: ''; current: #{$export_prefix})
125
129
  -E comma-seperated list of event types to show and export (default: all; current: #{$event_names.join(',')})
@@ -288,12 +292,21 @@ end
288
292
 
289
293
  puts "Found #{$datasets.length} datasets: #{$datasets.values.join('; ')}"
290
294
 
295
+ if $show_error_stats
296
+ $datasets.keys.sort.each do |imei|
297
+ dataset = $datasets[imei]
298
+ events = dataset.sorted # required to get the errors count
299
+ puts "Found #{dataset.errors.keys.length} errors in #{dataset.description}"
300
+ dataset.report_errors
301
+ end
302
+ end
303
+
291
304
  $datasets.keys.sort.each do |imei|
292
305
  dataset = $datasets[imei]
293
306
  imsi = dataset.imsi
294
307
  events = dataset.sorted
295
308
  puts if($print)
296
- puts "Found #{dataset.description}"
309
+ puts "Found #{dataset.description}" if($verbose || $print || $export)
297
310
  if $verbose
298
311
  puts "\tFirst Event: #{dataset.first}"
299
312
  puts "\tLast Event: #{dataset.last}"
data/lib/geoptima/data.rb CHANGED
@@ -235,6 +235,7 @@ module Geoptima
235
235
  geoptima['events'].each do |data|
236
236
  events = data['values']
237
237
  event_type = data.keys.reject{|k| k=~/values/}[0]
238
+ event_count = data[event_type]
238
239
  header = @events_metadata[event_type]
239
240
  # If the JSON is broken (known bug on some releases of the iPhone app)
240
241
  # Then get the header information from a list of known headers
@@ -245,17 +246,26 @@ module Geoptima
245
246
  end
246
247
  # Double-check the header length matches a multiple of the data length
247
248
  if header
248
- mismatch = events.length % header.length
249
- if mismatch != 0
250
- puts "'#{event_type}' header length #{header.length} incompatible with data length #{events.length}"
249
+ mismatch_records = events.length - header.length * event_count
250
+ if mismatch_records != 0
251
+ puts "'#{event_type}' header length #{header.length} incompatible with data length #{events.length} and record count #{event_count}"
251
252
  header = nil
252
253
  incr_error "Metadata mismatch"
253
254
  if Event::ALT_HEADERS.keys.grep(event_type).length>0
254
255
  incr_error "#{Event::HEADER_BUGS[event_type]} #{event_type}"
255
256
  [Event::KNOWN_HEADERS[event_type],*(Event::ALT_HEADERS[event_type])].each do |alt_header|
256
- if alt_header && (events.length % alt_header.length) == 0
257
- header = alt_header
258
- puts "Found alternative header that matches #{event_type}: #{header.join(',')}"
257
+ puts "Trying alternative header: #{alt_header.inspect}" if($debug)
258
+ if alt_header && (events.length == alt_header.length * event_count)
259
+ puts "\tAlternative header length matches: #{alt_header.inspect}" if($debug)
260
+ records_valid = (0...[10,event_count].min).inject(true) do |vt,ri|
261
+ timeoffset = events[ri*alt_header.length]
262
+ vt &&= timeoffset.is_a?(Fixnum)
263
+ end
264
+ if records_valid
265
+ header = alt_header
266
+ puts "Found alternative header that matches #{event_type}: #{header.join(',')}"
267
+ break
268
+ end
259
269
  end
260
270
  end
261
271
  end
@@ -1,6 +1,6 @@
1
1
  module Geoptima
2
2
 
3
- VERSION = "0.1.9"
3
+ VERSION = "0.1.10"
4
4
 
5
5
  class Version
6
6
  attr_reader :comparator, :version, :major, :minor, :patch
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: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 9
10
- version: 0.1.9
9
+ - 10
10
+ version: 0.1.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Craig Taverner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-29 00:00:00 Z
18
+ date: 2012-05-30 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: multi_json