cleanup APIs a bit
This commit is contained in:
@@ -24,7 +24,7 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
Source(Map& map, Transform& transform, Painter& painter, Texturepool& texturepool, const char *url = "", float pixel_ratio = 1.0, Type type = Type::vector, std::list<uint32_t> zooms = {0}, uint32_t tile_size = 512, uint32_t min_zoom = 0, uint32_t max_zoom = 14, bool enabled = true);
|
||||
Source(Map& map, Transform& transform, Painter& painter, Texturepool& texturepool, const char *url = "", Type type = Type::vector, std::list<uint32_t> zooms = {0}, uint32_t tile_size = 512, uint32_t min_zoom = 0, uint32_t max_zoom = 14, bool enabled = true);
|
||||
|
||||
bool update();
|
||||
void prepare_render(bool is_baselayer = false);
|
||||
@@ -43,8 +43,6 @@ private:
|
||||
TileData::State addTile(const Tile::ID& id);
|
||||
TileData::State hasTile(const Tile::ID& id);
|
||||
|
||||
void renderTile(const Tile::ID& id);
|
||||
|
||||
double getZoom() const;
|
||||
|
||||
private:
|
||||
@@ -60,8 +58,6 @@ private:
|
||||
uint32_t min_zoom;
|
||||
uint32_t max_zoom;
|
||||
|
||||
float pixel_ratio;
|
||||
|
||||
std::forward_list<Tile> tiles;
|
||||
std::forward_list<std::weak_ptr<TileData>> tile_data;
|
||||
};
|
||||
|
||||
@@ -43,7 +43,6 @@ void Map::setup(float pixelRatio) {
|
||||
painter,
|
||||
texturepool,
|
||||
"http://a.gl-api-us-east-1.tilestream.net/v3/mapbox.mapbox-streets-v4/%d/%d/%d.gl.pbf",
|
||||
pixelRatio,
|
||||
Source::Type::vector,
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14},
|
||||
512,
|
||||
@@ -57,7 +56,6 @@ void Map::setup(float pixelRatio) {
|
||||
painter,
|
||||
texturepool,
|
||||
"https://a.tiles.mapbox.com/v3/justin.hh0gkdfm/%d/%d/%d%s.png256",
|
||||
pixelRatio,
|
||||
Source::Type::raster,
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21},
|
||||
256,
|
||||
|
||||
@@ -11,13 +11,12 @@
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
Source::Source(Map& map, Transform& transform, Painter& painter, Texturepool& texturepool, const char *url, float pixel_ratio, Source::Type type, std::list<uint32_t> zooms, uint32_t tile_size, uint32_t min_zoom, uint32_t max_zoom, bool enabled)
|
||||
Source::Source(Map& map, Transform& transform, Painter& painter, Texturepool& texturepool, const char *url, Source::Type type, std::list<uint32_t> zooms, uint32_t tile_size, uint32_t min_zoom, uint32_t max_zoom, bool enabled)
|
||||
: map(map),
|
||||
transform(transform),
|
||||
painter(painter),
|
||||
texturepool(texturepool),
|
||||
url(url),
|
||||
pixel_ratio(pixel_ratio),
|
||||
type(type),
|
||||
zooms(zooms),
|
||||
tile_size(tile_size),
|
||||
@@ -115,7 +114,7 @@ TileData::State Source::addTile(const Tile::ID& id) {
|
||||
if (type == Source::Type::vector) {
|
||||
formed_url = util::sprintf(url, id.z, id.x, id.y);
|
||||
} else {
|
||||
formed_url = util::sprintf(url, id.z, id.x, id.y, (pixel_ratio > 1.0 ? "@2x" : ""));
|
||||
formed_url = util::sprintf(url, id.z, id.x, id.y, (map.getPixelRatio() > 1.0 ? "@2x" : ""));
|
||||
}
|
||||
|
||||
new_tile.data = std::make_shared<TileData>(normalized_id, map.getStyle(), map.getGlyphAtlas(), formed_url, (type == Source::Type::raster));
|
||||
@@ -271,13 +270,6 @@ bool Source::updateTiles() {
|
||||
return changed;
|
||||
}
|
||||
|
||||
void Source::renderTile(const Tile::ID& id) {
|
||||
|
||||
// painter.render(tile);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Taken from polymaps src/Layer.js
|
||||
// https://github.com/simplegeo/polymaps/blob/master/src/Layer.js#L333-L383
|
||||
|
||||
@@ -342,7 +334,7 @@ void _scanTriangle(const llmr::vec2<double> a, const llmr::vec2<double> b, const
|
||||
|
||||
double Source::getZoom() const {
|
||||
double offset = log(util::tileSize / tile_size) / log(2);
|
||||
offset += (pixel_ratio > 1.0 ? 1 :0);
|
||||
offset += (map.getPixelRatio() > 1.0 ? 1 :0);
|
||||
return map.getZoom() + offset;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user