This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] Implement TileCover for polygonal regions #11267
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7095b39
[core] Cleanup TileCount and remove extra Projection code
7bf6a35
[core] Streaming TileCover for lines and polygons
af2c2ce
[core] Tests for TileCover
4bda046
Support Multi-geometry and add tests
7cabdc3
Use points directly, instead of building edges.
d2933ae
Fixup comments
1a147fe
Use non-zero rule to span multi-polygons in a single pass
8c6534b
Ue smart pointer and remove unnecessary headers
0c0a581
Rename and fix Multi-Poly/Line when there is a y-gap between instances
7d88d1a
Implement per-tile strreaming. Cleanup and rename types and member va…
1193859
Fix signed-unsigned comparison
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#include <benchmark/benchmark.h> | ||
#include <mbgl/util/geo.hpp> | ||
#include <mbgl/util/geometry.hpp> | ||
#include <mbgl/util/tile_coordinate.hpp> | ||
#include <mbgl/util/tile_cover.hpp> | ||
#include <mbgl/map/transform.hpp> | ||
|
||
using namespace mbgl; | ||
|
||
static const LatLngBounds sanFrancisco = | ||
LatLngBounds::hull({ 37.6609, -122.5744 }, { 37.8271, -122.3204 }); | ||
|
||
static void TileCountBounds(benchmark::State& state) { | ||
std::size_t length = 0; | ||
while (state.KeepRunning()) { | ||
auto count = util::tileCount(sanFrancisco, 10); | ||
length += count; | ||
} | ||
} | ||
|
||
static void TileCoverPitchedViewport(benchmark::State& state) { | ||
Transform transform; | ||
transform.resize({ 512, 512 }); | ||
// slightly offset center so that tile order is better defined | ||
transform.setLatLng({ 0.1, -0.1 }); | ||
transform.setZoom(8); | ||
transform.setAngle(5.0); | ||
transform.setPitch(40.0 * M_PI / 180.0); | ||
|
||
std::size_t length = 0; | ||
while (state.KeepRunning()) { | ||
auto tiles = util::tileCover(transform.getState(), 8); | ||
length += tiles.size(); | ||
} | ||
} | ||
|
||
static void TileCoverBounds(benchmark::State& state) { | ||
std::size_t length = 0; | ||
while (state.KeepRunning()) { | ||
auto tiles = util::tileCover(sanFrancisco, 8); | ||
length += tiles.size(); | ||
} | ||
} | ||
|
||
static const auto geomPolygon = Polygon<double>{ | ||
{ | ||
{-122.5143814086914,37.779127216982424}, | ||
{-122.50811576843262,37.72721239056709}, | ||
{-122.50313758850099,37.70820178063929}, | ||
{-122.3938751220703,37.707454835665274}, | ||
{-122.37567901611328,37.70663997801684}, | ||
{-122.36297607421874,37.71343018466285}, | ||
{-122.354736328125,37.727280276860036}, | ||
{-122.36469268798828,37.73868429065797}, | ||
{-122.38014221191408,37.75442980295571}, | ||
{-122.38391876220702,37.78753873820529}, | ||
{-122.35919952392578,37.8065289741725}, | ||
{-122.35679626464844,37.820632846207864}, | ||
{-122.3712158203125,37.835276322922695}, | ||
{-122.3818588256836,37.82958198283902}, | ||
{-122.37190246582031,37.80788523279169}, | ||
{-122.38735198974608,37.791337175930686}, | ||
{-122.40966796874999,37.812767557570204}, | ||
{-122.46425628662108,37.807071480609274}, | ||
{-122.46803283691405,37.810326435534755}, | ||
{-122.47901916503906,37.81168262440736}, | ||
{-122.48966217041016,37.78916666399649}, | ||
{-122.50579833984375,37.78781006166096}, | ||
{-122.5143814086914,37.779127216982424} | ||
} | ||
}; | ||
|
||
static void TileCoverPolygon(benchmark::State& state) { | ||
std::size_t length = 0; | ||
|
||
while (state.KeepRunning()) { | ||
auto tiles = util::tileCover(geomPolygon, 8); | ||
length += tiles.size(); | ||
} | ||
} | ||
|
||
static void TileCountPolygon(benchmark::State& state) { | ||
std::size_t length = 0; | ||
|
||
while (state.KeepRunning()) { | ||
auto tiles = util::tileCount(geomPolygon, 16); | ||
length += tiles; | ||
} | ||
} | ||
|
||
BENCHMARK(TileCountBounds); | ||
BENCHMARK(TileCountPolygon); | ||
BENCHMARK(TileCoverPitchedViewport); | ||
BENCHMARK(TileCoverBounds); | ||
BENCHMARK(TileCoverPolygon); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,6 @@ set(MBGL_BENCHMARK_FILES | |
|
||
# util | ||
benchmark/util/dtoa.benchmark.cpp | ||
benchmark/util/tilecover.benchmark.cpp | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method projects to a tile fraction and not to a tile-size based world. I'm not sure if it should be called
project
or exposed fromTileCoordinate