[OSM-dev] Delta-encoding in PBF

2010-12-18 Thread David Paleino
Hello people,
I'm writing a parser in C# for PBF dumps. However, I'm having issues with the
Delta-{en|de}coding.
I thought I succesfully implemented the decoding when I saw correct
latitudes/longitudes, with the following (pseudo-)code:

---8---
function decode(delta) {
ret = []
for (i=0; i  delta.Count; i++) {
if (i == 0) {
ret.append(delta[0])
continue
}
ret.append(delta[0] + delta[i])
}
return ret
}
---8---

This worked great with latitudes/longitudes, which I converted with the

OUT = IN * granularity / 10**9

formula I found in the .proto.

However, it seems that I can't understand the way user_sid is encoded. I tried
to apply the same function, but it returned negative numbers at a certain
point, and I obviously had an OutOfRange exception.

I must also say that I originally thought that the delta-encoding worked like
this:

 1) write the first number, at list[0]
 2) at position n, write the result of list[n-1] - list[n]

Did I just miss the correct documentation?

Thank you,
David

-- 
 . ''`.   Debian developer | http://wiki.debian.org/DavidPaleino
 : :'  : Linuxer #334216 --|-- http://www.hanskalabs.net/
 `. `'`  GPG: 1392B174 | http://deb.li/dapal
   `-   2BAB C625 4E66 E7B8 450A C3E1 E6AA 9017 1392 B174


signature.asc
Description: PGP signature
___
dev mailing list
dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/dev


Re: [OSM-dev] Delta-encoding in PBF

2010-12-18 Thread Stefan de Konink
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Op 18-12-10 11:53, David Paleino schreef:
 Hello people,
 I'm writing a parser in C# for PBF dumps. However, I'm having issues with the
 Delta-{en|de}coding.

http://git.openstreetmap.nl/index.cgi/pbf2osm.git/tree/src/main.c#n588


Maybe that helps?


Stefan
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEAREKAAYFAk0MqNkACgkQYH1+F2Rqwn08DgCdFg0+MpUVGwkyRVMTPhqOlWFR
CjIAniL8AqWbBMhU1LkwQWT0qMZOPuBW
=kyDH
-END PGP SIGNATURE-

___
dev mailing list
dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/dev


Re: [OSM-dev] Delta-encoding in PBF

2010-12-18 Thread David Paleino
On Sat, 18 Dec 2010 13:28:09 +0100, Stefan de Konink wrote:

 Op 18-12-10 11:53, David Paleino schreef:
  Hello people,
  I'm writing a parser in C# for PBF dumps. However, I'm having issues with
  the Delta-{en|de}coding.
 
 http://git.openstreetmap.nl/index.cgi/pbf2osm.git/tree/src/main.c#n588
 
 Maybe that helps?

Aha, yes! :)

From that code, it seems like you're using what I thought before, i.e. given x,
x1 and x2, the delta-coded list would contain x, x1-x, x2-x1. And then you're
reconstructing them just by summing up.

So I found my bug. I was summing up deltas between them, instead of
previous result + current delta.

Thank you!,
David

-- 
 . ''`.   Debian developer | http://wiki.debian.org/DavidPaleino
 : :'  : Linuxer #334216 --|-- http://www.hanskalabs.net/
 `. `'`  GPG: 1392B174 | http://deb.li/dapal
   `-   2BAB C625 4E66 E7B8 450A C3E1 E6AA 9017 1392 B174


signature.asc
Description: PGP signature
___
dev mailing list
dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/dev


Re: [OSM-dev] Delta-encoding in PBF

2010-12-18 Thread Scott Crosby
On Sat, Dec 18, 2010 at 6:28 AM, Stefan de Konink ste...@konink.de wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA512

 Op 18-12-10 11:53, David Paleino schreef:
 Hello people,
 I'm writing a parser in C# for PBF dumps. However, I'm having issues with the
 Delta-{en|de}coding.

 http://git.openstreetmap.nl/index.cgi/pbf2osm.git/tree/src/main.c#n588


Thanks.

Also to add to this, the reference implementation of PBF is the
osmosis implementation, split between Osmosis (at
http://svn.openstreetmap.org/applications/utils/osmosis/trunk/pbf/)
and the application generic part at
https://github.com/scrosby/OSM-binary which contains the master PBF
definitions and is used to build osmbin.jar.

Scott

___
dev mailing list
dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/dev