# turns a spherical mercator coord into a tile coord
def self.tile_from_merc(point, zoom)
# turns a spherical mercator coord into a tile coord
def self.tile_from_merc(point, zoom)
# we put all the nodes into the hash, as it doesn't matter whether the node was
# added, deleted or modified - the tile will need updating anyway.
# we put all the nodes into the hash, as it doesn't matter whether the node was
# added, deleted or modified - the tile will need updating anyway.
# itself deleted and the coverage of the point set isn't enough to encompass the
# change.
node_cache = NodeCache.new(NODE_CACHE_FILE)
# itself deleted and the coverage of the point set isn't enough to encompass the
# change.
node_cache = NodeCache.new(NODE_CACHE_FILE)
next if nodes.include? node_id
# this is a node referenced but not added, modified or deleted, so it should
# still be in the node cache.
next if nodes.include? node_id
# this is a node referenced but not added, modified or deleted, so it should
# still be in the node cache.
point = Proj4::Point.new(entry.lon, entry.lat)
nodes[node_id] = tile_from_merc(point, max_zoom)
end
end
point = Proj4::Point.new(entry.lon, entry.lat)
nodes[node_id] = tile_from_merc(point, max_zoom)
end
end
# create a set of all the tiles at the maximum zoom level which are touched by
# any of the nodes we've collected. we'll create the tiles at other zoom levels
# create a set of all the tiles at the maximum zoom level which are touched by
# any of the nodes we've collected. we'll create the tiles at other zoom levels
- throw "Unexpected format" unless @cache[0..3].unpack("l").first == 1
- throw "Unexpected ID size" unless @cache[4..7].unpack("l").first == 8
+ throw "Unexpected format" unless @cache.sysread(4).unpack("l").first == 1
+ throw "Unexpected ID size" unless @cache.sysread(4).unpack("l").first == 8
if lon != -2147483648 && lat != -2147483648
node = Node.new(lon, lat)
if lon != -2147483648 && lat != -2147483648
node = Node.new(lon, lat)