pbf_parser 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/ext/pbf_parser/pbf_parser.c +46 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72b430f0eb6a15d794fb46e5a0abb20f57fc17d1
4
- data.tar.gz: dcae3bf18500db3c8b6d4108e7b2e1e7e70681b4
3
+ metadata.gz: 0489b9514ead9c6a13ec957aeb4b9a1d48c75192
4
+ data.tar.gz: caaed36535aa45774e11a094c6a78ba958f90e5e
5
5
  SHA512:
6
- metadata.gz: a3133b5fc953f64b3aca5d3bdc7d3acb4d06be5d7bfd42c20f73c173a4ba866f6deddfe114f9c2c27f5f50ea4d25e6b6081e21c00c0bb97137f2db8f11f8c70b
7
- data.tar.gz: 68aca200b0b993d3c3d182e65d0c245af5da739076de5e6079086b2fe36c0f28db945bcc9288dd883009a7c4983094b6ee613c3bff1ec3704d6ae3db3135df3a
6
+ metadata.gz: d0b68e7154c00312ad96632f78467715e75a2c04154a9e450c37af2e1e5a1e3ec9e6af488c5c6550b7db7821933c5a6cfd05a74f2a5449b29a6094875ce66279
7
+ data.tar.gz: 46afa2839cf2ec0356c9100966c58a6817c992fda301b0900ef0436ddf47d2c8b5782a57de4847cfe16a030aef170ac384d53c4ab4b9898c50207acf1609214a
@@ -176,7 +176,17 @@ static void add_info(VALUE hash, Info *info, StringTable *string_table, double t
176
176
  timestamp = info->timestamp ? LL2NUM(info->timestamp * ts_granularity) : Qnil;
177
177
  changeset = info->changeset ? LL2NUM(info->changeset) : Qnil;
178
178
  uid = info->uid ? INT2NUM(info->uid) : Qnil;
179
- user = info->user_sid ? str_new(parse_binary_str(string_table->s[info->user_sid])) : Qnil;
179
+
180
+ if(info->user_sid)
181
+ {
182
+ char *user_sid = parse_binary_str(string_table->s[info->user_sid]);
183
+ user = str_new(user_sid);
184
+ free(user_sid);
185
+ }
186
+ else
187
+ user = Qnil;
188
+
189
+ free(user_sid);
180
190
 
181
191
  rb_hash_aset(hash, STR2SYM("version"), version);
182
192
  rb_hash_aset(hash, STR2SYM("timestamp"), timestamp);
@@ -205,6 +215,8 @@ static int parse_osm_header(VALUE obj, FILE *input)
205
215
  blob = read_blob(input, datasize, &blob_length);
206
216
  header_block = header_block__unpack(NULL, blob_length, blob);
207
217
 
218
+ free(blob);
219
+
208
220
  if(header_block == NULL)
209
221
  rb_raise(rb_eIOError, "Unable to unpack the HeaderBlock");
210
222
 
@@ -220,11 +232,13 @@ static int parse_osm_header(VALUE obj, FILE *input)
220
232
  VALUE osmosis_replication_sequence_number = Qnil;
221
233
  VALUE osmosis_replication_base_url = Qnil;
222
234
 
235
+ int i = 0;
236
+
223
237
  if(header_block->n_required_features > 0)
224
238
  {
225
239
  required_features = rb_ary_new();
226
240
 
227
- for(int i = 0; i < (int)header_block->n_required_features; i++)
241
+ for(i = 0; i < (int)header_block->n_required_features; i++)
228
242
  rb_ary_push(required_features, str_new(header_block->required_features[i]));
229
243
  }
230
244
 
@@ -232,7 +246,7 @@ static int parse_osm_header(VALUE obj, FILE *input)
232
246
  {
233
247
  optional_features = rb_ary_new();
234
248
 
235
- for(int i = 0; i < (int)header_block->n_optional_features; i++)
249
+ for(i = 0; i < (int)header_block->n_optional_features; i++)
236
250
  rb_ary_push(optional_features, str_new(header_block->optional_features[i]));
237
251
  }
238
252
 
@@ -279,9 +293,10 @@ static void process_nodes(VALUE out, PrimitiveGroup *group, StringTable *string_
279
293
  {
280
294
  double lat = 0;
281
295
  double lon = 0;
282
- unsigned j;
296
+ unsigned j = 0;
297
+ size_t i = 0;
283
298
 
284
- for(size_t i = 0; i < group->n_nodes; i++)
299
+ for(i = 0; i < group->n_nodes; i++)
285
300
  {
286
301
  Node *node = group->nodes[i];
287
302
  VALUE node_out = rb_hash_new();
@@ -304,6 +319,9 @@ static void process_nodes(VALUE out, PrimitiveGroup *group, StringTable *string_
304
319
  char *value = parse_binary_str(string_table->s[node->vals[j]]);
305
320
 
306
321
  rb_hash_aset(tags, str_new(key), str_new(value));
322
+
323
+ free(key);
324
+ free(value);
307
325
  }
308
326
 
309
327
  rb_hash_aset(node_out, STR2SYM("tags"), tags);
@@ -325,8 +343,9 @@ static void process_dense_nodes(VALUE out, DenseNodes *dense_nodes, StringTable
325
343
  double lon = 0;
326
344
 
327
345
  unsigned j = 0;
346
+ size_t i = 0;
328
347
 
329
- for(size_t i = 0; i < dense_nodes->n_id; i++)
348
+ for(i = 0; i < dense_nodes->n_id; i++)
330
349
  {
331
350
  VALUE node = rb_hash_new();
332
351
 
@@ -372,6 +391,9 @@ static void process_dense_nodes(VALUE out, DenseNodes *dense_nodes, StringTable
372
391
 
373
392
  rb_hash_aset(tags, str_new(key), str_new(value));
374
393
 
394
+ free(key);
395
+ free(value);
396
+
375
397
  j += 2;
376
398
  }
377
399
  j += 1;
@@ -385,8 +407,9 @@ static void process_dense_nodes(VALUE out, DenseNodes *dense_nodes, StringTable
385
407
  static void process_ways(VALUE out, PrimitiveGroup *group, StringTable *string_table, int32_t ts_granularity)
386
408
  {
387
409
  unsigned j, k;
410
+ size_t i = 0;
388
411
 
389
- for(size_t i = 0; i < group->n_ways; i++)
412
+ for(i = 0; i < group->n_ways; i++)
390
413
  {
391
414
  Way *way = group->ways[i];
392
415
  int64_t delta_refs = 0;
@@ -404,6 +427,9 @@ static void process_ways(VALUE out, PrimitiveGroup *group, StringTable *string_t
404
427
  char *value = parse_binary_str(string_table->s[way->vals[j]]);
405
428
 
406
429
  rb_hash_aset(tags, str_new(key), str_new(value));
430
+
431
+ free(key);
432
+ free(value);
407
433
  }
408
434
 
409
435
  // Extract refs
@@ -428,8 +454,9 @@ static void process_ways(VALUE out, PrimitiveGroup *group, StringTable *string_t
428
454
  static void process_relations(VALUE out, PrimitiveGroup *group, StringTable *string_table, int32_t ts_granularity)
429
455
  {
430
456
  unsigned j, k;
457
+ size_t i = 0;
431
458
 
432
- for(size_t i = 0; i < group->n_relations; i++)
459
+ for(i = 0; i < group->n_relations; i++)
433
460
  {
434
461
  Relation *relation = group->relations[i];
435
462
  VALUE relation_out = rb_hash_new();
@@ -445,6 +472,9 @@ static void process_relations(VALUE out, PrimitiveGroup *group, StringTable *str
445
472
  char *value = parse_binary_str(string_table->s[relation->vals[j]]);
446
473
 
447
474
  rb_hash_aset(tags, str_new(key), str_new(value));
475
+
476
+ free(key);
477
+ free(value);
448
478
  }
449
479
 
450
480
  // Extract members
@@ -464,8 +494,12 @@ static void process_relations(VALUE out, PrimitiveGroup *group, StringTable *str
464
494
 
465
495
  rb_hash_aset(member, STR2SYM("id"), LL2NUM(delta_memids));
466
496
 
467
- if(role = parse_binary_str(string_table->s[relation->roles_sid[k]]))
497
+ if(relation->roles_sid[k])
498
+ {
499
+ role = parse_binary_str(string_table->s[relation->roles_sid[k]]);
468
500
  rb_hash_aset(member, STR2SYM("role"), str_new(role));
501
+ free(role);
502
+ }
469
503
 
470
504
  switch(relation->types[k])
471
505
  {
@@ -535,7 +569,9 @@ static VALUE parse_osm_data(VALUE obj)
535
569
  VALUE ways = rb_hash_aref(data, STR2SYM("ways"));
536
570
  VALUE relations = rb_hash_aref(data, STR2SYM("relations"));
537
571
 
538
- for(size_t i = 0; i < primitive_block->n_primitivegroup; i++)
572
+ size_t i = 0;
573
+
574
+ for(i = 0; i < primitive_block->n_primitivegroup; i++)
539
575
  {
540
576
  PrimitiveGroup *primitive_group = primitive_block->primitivegroup[i];
541
577
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbf_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrià Planas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-05 00:00:00.000000000 Z
11
+ date: 2013-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler