[core] Fix render tile ordering when querying sources
This commit is contained in:
committed by
Jesse Bounds
parent
610f43cfd2
commit
b7818f2019
@@ -23,7 +23,7 @@
|
||||
"lodash": "^4.16.4",
|
||||
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#98a56d538b11fb331aa67a6d632d6ecd6821b007",
|
||||
"mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#7f62a4fc9f21e619824d68abbc4b03cbc1685572",
|
||||
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#10a135f01b56989aa03686de94cc67c3efa6139d",
|
||||
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#8d2d9cb86a7b4a15bc5a59bab531cd102257918d",
|
||||
"mkdirp": "^0.5.1",
|
||||
"node-cmake": "^1.2.1",
|
||||
"request": "^2.72.0",
|
||||
|
||||
@@ -201,8 +201,19 @@ std::unordered_map<std::string, std::vector<Feature>> Source::Impl::queryRendere
|
||||
|
||||
mapbox::geometry::box<double> box = mapbox::geometry::envelope(queryGeometry);
|
||||
|
||||
for (const auto& tilePtr : renderTiles) {
|
||||
const RenderTile& renderTile = tilePtr.second;
|
||||
|
||||
auto sortRenderTiles = [](const RenderTile& a, const RenderTile& b) {
|
||||
return a.id.canonical.z != b.id.canonical.z ? a.id.canonical.z < b.id.canonical.z :
|
||||
a.id.canonical.y != b.id.canonical.y ? a.id.canonical.y < b.id.canonical.y :
|
||||
a.id.wrap != b.id.wrap ? a.id.wrap < b.id.wrap : a.id.canonical.x < b.id.canonical.x;
|
||||
};
|
||||
std::vector<std::reference_wrapper<const RenderTile>> sortedTiles;
|
||||
std::transform(renderTiles.cbegin(), renderTiles.cend(), std::back_inserter(sortedTiles),
|
||||
[](const auto& pair) { return std::ref(pair.second); });
|
||||
std::sort(sortedTiles.begin(), sortedTiles.end(), sortRenderTiles);
|
||||
|
||||
for (const auto& renderTileRef : sortedTiles) {
|
||||
const RenderTile& renderTile = renderTileRef.get();
|
||||
GeometryCoordinate tileSpaceBoundsMin = TileCoordinate::toGeometryCoordinate(renderTile.id, box.min);
|
||||
if (tileSpaceBoundsMin.x >= util::EXTENT || tileSpaceBoundsMin.y >= util::EXTENT) {
|
||||
continue;
|
||||
|
||||
@@ -108,12 +108,7 @@ inline bool CanonicalTileID::operator!=(const CanonicalTileID& rhs) const {
|
||||
}
|
||||
|
||||
inline bool CanonicalTileID::operator<(const CanonicalTileID& rhs) const {
|
||||
if (z != rhs.z) {
|
||||
return z < rhs.z;
|
||||
} else if (x != rhs.x) {
|
||||
return x < rhs.x;
|
||||
}
|
||||
return y < rhs.y;
|
||||
return z != rhs.z ? z < rhs.z : x != rhs.x ? x < rhs.x : y < rhs.y;
|
||||
}
|
||||
|
||||
inline bool CanonicalTileID::isChildOf(const CanonicalTileID& parent) const {
|
||||
@@ -175,10 +170,7 @@ inline bool OverscaledTileID::operator!=(const OverscaledTileID& rhs) const {
|
||||
}
|
||||
|
||||
inline bool OverscaledTileID::operator<(const OverscaledTileID& rhs) const {
|
||||
if (overscaledZ != rhs.overscaledZ) {
|
||||
return overscaledZ < rhs.overscaledZ;
|
||||
}
|
||||
return canonical < rhs.canonical;
|
||||
return overscaledZ != rhs.overscaledZ ? overscaledZ < rhs.overscaledZ : canonical < rhs.canonical;
|
||||
}
|
||||
|
||||
inline uint32_t OverscaledTileID::overscaleFactor() const {
|
||||
@@ -191,11 +183,7 @@ inline bool OverscaledTileID::isChildOf(const OverscaledTileID& rhs) const {
|
||||
}
|
||||
|
||||
inline OverscaledTileID OverscaledTileID::scaledTo(uint8_t z) const {
|
||||
if (z >= canonical.z) {
|
||||
return { z, canonical };
|
||||
} else {
|
||||
return { z, canonical.scaledTo(z) };
|
||||
}
|
||||
return { z, z >= canonical.z ? canonical : canonical.scaledTo(z) };
|
||||
}
|
||||
|
||||
inline UnwrappedTileID OverscaledTileID::unwrapTo(int16_t wrap) const {
|
||||
@@ -223,10 +211,7 @@ inline bool UnwrappedTileID::operator!=(const UnwrappedTileID& rhs) const {
|
||||
}
|
||||
|
||||
inline bool UnwrappedTileID::operator<(const UnwrappedTileID& rhs) const {
|
||||
if (wrap != rhs.wrap) {
|
||||
return wrap < rhs.wrap;
|
||||
}
|
||||
return canonical < rhs.canonical;
|
||||
return wrap != rhs.wrap ? wrap < rhs.wrap : canonical < rhs.canonical;
|
||||
}
|
||||
|
||||
inline bool UnwrappedTileID::isChildOf(const UnwrappedTileID& parent) const {
|
||||
|
||||
Reference in New Issue
Block a user