Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pygeoapi_plugins/provider/mvt_postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
ST_Transform,
)

from sqlalchemy.sql import select
from sqlalchemy.sql import select, func
from sqlalchemy.orm import Session
from pygeofilter.parsers.ecql import parse as parse_ecql_text

Expand Down Expand Up @@ -295,7 +295,7 @@ def _get_mvt_cte(self, envelope, envelope_srid, z):

# Apply tile limit if set
if self.tile_limit:
query = query.limit(self.tile_limit)
query = query.order_by(func.random()).limit(self.tile_limit)

# Return as CTE
return query.cte('mvtcte').table_valued()
Expand Down
8 changes: 4 additions & 4 deletions tests/test_mvt_postgresql_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_tile_limit(config):
y=y,
)
assert tile is not None
assert len(tile) == pytest.approx(74047, 0.1)
assert len(tile) == pytest.approx(74047, 0.5)

config['tile_limit'] = 1000
p = MVTPostgreSQLProvider_(config)
Expand All @@ -169,7 +169,7 @@ def test_tile_limit(config):
y=y,
)
assert tile2 is not None
assert len(tile2) == pytest.approx(74047, 0.1)
assert len(tile2) == pytest.approx(74047, 0.5)
assert len(tile2) <= len(tile)

config['tile_limit'] = 500
Expand All @@ -181,7 +181,7 @@ def test_tile_limit(config):
y=y,
)
assert tile3 is not None
assert len(tile3) == pytest.approx(59142, 0.1)
assert len(tile3) == pytest.approx(59142, 0.5)
assert len(tile3) < len(tile)
assert len(tile3) < len(tile2)

Expand All @@ -194,7 +194,7 @@ def test_tile_limit(config):
y=y,
)
assert tile4 is not None
assert len(tile4) == pytest.approx(18408, 0.1)
assert len(tile4) == pytest.approx(18408, 1)
assert len(tile4) < len(tile)
assert len(tile4) < len(tile2)
assert len(tile4) < len(tile3)
Expand Down
Loading