gpslist.each do |row|
xs = (long2coord(row['lon'].to_f, baselong, masterscale) * 20).floor
ys = (lat2coord(row['lat'].to_f, basey, masterscale) * 20).floor
gpslist.each do |row|
xs = (long2coord(row['lon'].to_f, baselong, masterscale) * 20).floor
ys = (lat2coord(row['lat'].to_f, basey, masterscale) * 20).floor
- b += startAndMove(xs, ys, '01')
- absx = xs.floor; absy = ys.floor
+ b += start_and_move(xs, ys, '01')
+ absx = xs.floor
+ absy = ys.floor
- b += drawTo(absx, absy, xs, ys)
- absx = xs.floor; absy = ys.floor
+ b += draw_to(absx, absy, xs, ys)
+ absx = xs.floor
+ absy = ys.floor
- m += swfRecord(2, packUI16(1) + packRect(xl, xr, yb, yt) + r)
- m += swfRecord(4, packUI16(1) + packUI16(1))
+ m += swf_record(2, pack_u16(1) + pack_rect(xl, xr, yb, yt) + r)
+ m += swf_record(4, pack_u16(1) + pack_u16(1))
- m += swfRecord(1, '') # Show frame
- m += swfRecord(0, '') # End
+ m += swf_record(1, '') # Show frame
+ m += swf_record(0, '') # End
- m = packRect(bounds_left, bounds_right, bounds_bottom, bounds_top) + 0.chr + 12.chr + packUI16(1) + m
- m = 'FWS' + 6.chr + packUI32(m.length + 8) + m
+ m = pack_rect(bounds_left, bounds_right, bounds_bottom, bounds_top) + 0.chr + 12.chr + pack_u16(1) + m
+ m = 'FWS' + 6.chr + pack_u32(m.length + 8) + m
- def startShape
- s = 0.chr # No fill styles
- s += 2.chr # Two line styles
- s += packUI16(0) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF
- s += packUI16(0) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF
+ def start_shape
+ s = 0.chr # No fill styles
+ s += 2.chr # Two line styles
+ s += pack_u16(0) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF
+ s += pack_u16(0) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF
- def startAndMove(x, y, col)
- d = '001001' # Line style change, moveTo
- l = [lengthSB(x), lengthSB(y)].max
+ def start_and_move(x, y, col)
+ d = '001001' # Line style change, moveTo
+ l = [length_sb(x), length_sb(y)].max
d += sprintf("%05b%0#{l}b%0#{l}b", l, x, y)
d += sprintf("%05b%0#{l}b%0#{l}b", l, x, y)
- def drawTo(absx, absy, x, y)
+ def draw_to(absx, absy, x, y)
- for i in (1..mstep)
- d += drawSection(x, y, x + xstep, y + ystep)
+ 1.upto(mstep).each do
+ d += draw_section(x, y, x + xstep, y + ystep)
- def drawSection(x1, y1, x2, y2)
+ def draw_section(x1, y1, x2, y2)
d += sprintf("%04b", l - 2)
d += '1' # GeneralLine
d += sprintf("%0#{l}b%0#{l}b", dx, dy)
d += sprintf("%04b", l - 2)
d += '1' # GeneralLine
d += sprintf("%0#{l}b%0#{l}b", dx, dy)
- def packRect(a, b, c, d)
- l = [lengthSB(a),
- lengthSB(b),
- lengthSB(c),
- lengthSB(d)].max
+ def pack_rect(a, b, c, d)
+ l = [length_sb(a),
+ length_sb(b),
+ length_sb(c),
+ length_sb(d)].max
# create binary string (00111001 etc.) - 5-byte length, then bbox
n = sprintf("%05b%0#{l}b%0#{l}b%0#{l}b%0#{l}b", l, a, b, c, d)
# pack into byte string
# create binary string (00111001 etc.) - 5-byte length, then bbox
n = sprintf("%05b%0#{l}b%0#{l}b%0#{l}b%0#{l}b", l, a, b, c, d)
# pack into byte string