geoptima 0.1.10 → 0.1.11

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.
@@ -0,0 +1,27 @@
1
+ {"geoptima": {
2
+ "Version": "3.4","json-version":"2.0",
3
+ "subscriber":{
4
+ "imsi":"240084701402127","imei":"357841036600753","msisdn":"Not Available",
5
+ "Manufacturer":"HTC","Model":"HTC Desire","OS":"Android 2.2",
6
+ "start":"Jul 8 2011 18:52:23.995 GMT+02:00"},
7
+ "events-metadata": [
8
+ {"gps": ["timeoffset","latitude","longitude","altitude","accuracy","direction","speed"]},
9
+ {"signal": ["timeoffset", "strength", "rxqual", "ecio"]},
10
+ {"service": ["timeoffset", "plmn", "cell_id", "lac", "mnc", "mcc"]},
11
+ {"call": ["timeoffset", "status"]}
12
+ ],
13
+ "events": [
14
+ {"gps":2, "values":[
15
+ 0,"56.058200","12.966367","78.0","6.0","59.0625","83.7",
16
+ 405,"56.058307","12.966710","78.0","6.0","59.414063","83.7"]},
17
+ {"signal":2, "values":[
18
+ 108704,-85,"-1","-1",
19
+ 111660,-83,"-1","-1"]},
20
+ {"service":2, "values":[
21
+ 340980822,"20205","3371977","6014","05","202",
22
+ 591987445,"24004","67575260","2311","04","240"]},
23
+ {"call":2, "values":[
24
+ 340981167,"idle",
25
+ 591987471,"idle"]}
26
+ ]
27
+ }}
data/lib/geoptima/data.rb CHANGED
@@ -94,8 +94,8 @@ module Geoptima
94
94
  }
95
95
 
96
96
  include ErrorCounter
97
- attr_reader :file, :header, :name, :data, :fields, :time, :latitude, :longitude
98
- def initialize(file,start,name,header,data)
97
+ attr_reader :file, :header, :name, :data, :fields, :time, :latitude, :longitude, :timeoffset
98
+ def initialize(file,start,name,header,data,previous=nil)
99
99
  @file = file
100
100
  @name = name
101
101
  @header = header
@@ -104,11 +104,20 @@ module Geoptima
104
104
  a[v] = check_field(@data[a.length])
105
105
  a
106
106
  end
107
- timeoffset = (@fields['timeoffset'].to_f / MSPERDAY.to_f)
108
- if(timeoffset<-0.0000001)
107
+ @timeoffset = (@fields['timeoffset'].to_f / MSPERDAY.to_f)
108
+ if(@timeoffset<-0.0000001)
109
109
  puts "Have negative time offset: #{@fields['timeoffset']}" if($debug)
110
110
  incr_error "#4506 negative offsets"
111
111
  end
112
+ if previous
113
+ prev_to = previous.timeoffset
114
+ puts "Comparing timeoffset:#{timeoffset} to previous:#{prev_to}" if($debug)
115
+ if @timeoffset == prev_to
116
+ puts "Found the same timeoffset in consecutive events: #{name}:#{timeoffset} == #{previous.name}:#{previous.timeoffset}"
117
+ incr_error "#4576 same timeoffset"
118
+ @timeoffset = @timeoffset + 1.0 / MSPERDAY.to_f
119
+ end
120
+ end
112
121
  @time = start + timeoffset
113
122
  @fields.reject!{|k,v| k=~/timeoffset/}
114
123
  if @fields['cell_id'].to_i > SHORT
@@ -235,7 +244,7 @@ module Geoptima
235
244
  geoptima['events'].each do |data|
236
245
  events = data['values']
237
246
  event_type = data.keys.reject{|k| k=~/values/}[0]
238
- event_count = data[event_type]
247
+ event_count = data[event_type].to_i
239
248
  header = @events_metadata[event_type]
240
249
  # If the JSON is broken (known bug on some releases of the iPhone app)
241
250
  # Then get the header information from a list of known headers
@@ -249,9 +258,14 @@ module Geoptima
249
258
  mismatch_records = events.length - header.length * event_count
250
259
  if mismatch_records != 0
251
260
  puts "'#{event_type}' header length #{header.length} incompatible with data length #{events.length} and record count #{event_count}"
261
+ proposed_header = header
252
262
  header = nil
253
263
  incr_error "Metadata mismatch"
254
- if Event::ALT_HEADERS.keys.grep(event_type).length>0
264
+ if events.length == proposed_header.length * event_count * 2 && event_type == 'roundtrip'
265
+ incr_error "#4593 iPhone roundtrip event counts"
266
+ event_count *= 2
267
+ header = proposed_header
268
+ elsif Event::ALT_HEADERS.keys.grep(event_type).length>0
255
269
  incr_error "#{Event::HEADER_BUGS[event_type]} #{event_type}"
256
270
  [Event::KNOWN_HEADERS[event_type],*(Event::ALT_HEADERS[event_type])].each do |alt_header|
257
271
  puts "Trying alternative header: #{alt_header.inspect}" if($debug)
@@ -275,13 +289,14 @@ module Geoptima
275
289
  end
276
290
  # Now process the single long data array into a list of events with timestamps
277
291
  if header
278
- events_data[event_type] = (0...data[event_type].to_i).inject([]) do |a,block|
292
+ events_data[event_type] = (0...event_count).inject([]) do |a,block|
279
293
  index = header.length * block
280
294
  record = events[index...(index+header.length)]
281
295
  if record && record.length == header.length
282
296
  @count += 1
283
- event = Event.new(self,start,event_type,header,record)
297
+ event = Event.new(self,start,event_type,header,record,a[-1])
284
298
  combine_errors event
299
+ puts "About to add new event #{event} to existing list of #{a.length} events (previous: #{a[-1] && a[-1].time})" if($debug)
285
300
  a << event
286
301
  else
287
302
  puts "Invalid '#{event_type}' data block #{block}: #{record.inspect}"
@@ -1,6 +1,6 @@
1
1
  module Geoptima
2
2
 
3
- VERSION = "0.1.10"
3
+ VERSION = "0.1.11"
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: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 10
10
- version: 0.1.10
9
+ - 11
10
+ version: 0.1.11
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-30 00:00:00 Z
18
+ date: 2012-06-07 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: multi_json
@@ -90,6 +90,7 @@ files:
90
90
  - examples/geoptima_file_time.rb
91
91
  - examples/csv_stats.rb
92
92
  - examples/sample_geoptima.json
93
+ - examples/sample_short.json
93
94
  - README.rdoc
94
95
  - CHANGELOG
95
96
  - CONTRIBUTORS