[OSM-dev] Ruby help - streams of bits
SteveC
steve at asklater.com
Thu May 17 13:36:38 BST 2007
can't you do something like
a = ''
a[0] = 123
to set byte 0 of a string to char 123?
On 17 May 2007, at 11:57, Richard Fairhurst wrote:
> Hi all,
>
> I'm working on removing the Ming dependency from Potlatch's GPS code.
> In other words, you won't need Ming to run Potlatch on your own
> machine - you'll only need it to compile the SWF if you want to make
> any changes to Potlatch.
>
> I've rewritten the getgps script to assemble the SWF 'manually', and
> it works exactly as it should. Only trouble is that it's a bit slow.
>
> SWF's opcodes and arguments are encoded as variable-length streams of
> bits. These are all packed in direct succession - i.e. not padded to
> byte boundaries or anything like that.
>
> So, for example, you might have
>
> 00111 5-bit record
> 0110101 7-bit record
> 0000110 7-bit record
> 0001100 7-bit record
> 1111101 7-bit record
>
> which would be packed as
>
> 0b00111011,0b01010000,0b11000011,0b00111110,0b10000000
> (final byte null-
> padded)
>
> At present I'm doing this by assembling a big big big binary string,
> then splitting it into eight-character strings and converting each one
> into a number. But this is dreadfully slow.
>
> Do any of the Ruby experts here have any better ideas?
>
> cheers
> Richard
>
>
> _______________________________________________
> dev mailing list
> dev at openstreetmap.org
> http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/dev
>
have fun,
SteveC | steve at asklater.com | http://www.asklater.com/steve/
More information about the dev
mailing list