Skip to content

Commit

Permalink
Note details of zigzag encoding.
Browse files Browse the repository at this point in the history
Also fix the encoding example, which didn't use zigzag encoding.

See #14.
  • Loading branch information
Sean Gillies committed May 8, 2014
1 parent 5e19d44 commit 1d35c94
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions 1.0.0/vector_tile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,23 @@ message tile {
// - LineTo: 2 (2 parameters follow)
// - ClosePath: 7 (no parameters follow)
//
// Commands are encoded as uint32 varints. Vertex parameters
// are encoded as deltas to the previous position and, as they
// may be negative, are further "zigzag" encoded as unsigned
// 32-bit ints:
//
// n = (n << 1) ^ (n >> 31)
//
// Ex.: MoveTo(3, 6), LineTo(8, 12), LineTo(20, 34), ClosePath
// Encoded as: [ 9 3 6 18 5 6 12 22 15 ]
// Encoded as: [ 9 6 12 18 10 12 24 44 15 ]

This comment has been minimized.

Copy link
@kkaefer

kkaefer May 8, 2014

Member

Whoops, never noticed the confusion here. Thanks for changing!

This comment has been minimized.

Copy link
@strk

strk Jul 25, 2014

The description below this line should be also updated

This comment has been minimized.

Copy link
@kkaefer

kkaefer Jul 29, 2014

Member

The description seems correct to me.

// == command type 7 (ClosePath), length 1
// ===== relative LineTo(+12, +22) == LineTo(20, 34)
// === relative LineTo(+5, +6) == LineTo(8, 12)
// == [00010 010] = command type 2 (LineTo), length 2
// === relative MoveTo(+3, +6)
// == [00001 001] = command type 1 (MoveTo), length 1
// Commands are encoded as uint32 varints, vertex parameters are
// encoded as sint32 varints (zigzag). Vertex parameters are
// also encoded as deltas to the previous position. The original
// position is (0,0)
//
// The original position is (0,0).
repeated uint32 geometry = 4 [ packed = true ];
}

Expand Down

3 comments on commit 1d35c94

@strk
Copy link

@strk strk commented on 1d35c94 Jul 29, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's about alignment, the equal signes used to be aligned to the column they referred to, but the columns were shifted after the change. Needs a fixed-length font to see.

@kkaefer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Should be fixed in c9be969

@strk
Copy link

@strk strk commented on 1d35c94 Jul 29, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, confirmed. Thanks!

Please sign in to comment.