perf(tiles): filter trails by length_m per zoom level
- z<=7: min 2000m, limit 3000 - z==8: min 500m, limit 8000 - z==9: min 200m, limit 8000 - z==10: min 50m, limit 15000 - z>=11: no filter, limit 25000 Reduces row count from 25k to ~hundreds on z8 tiles.
This commit is contained in:
@@ -252,14 +252,26 @@ async def get_tile(z: int, x: int, y: int):
|
||||
q_north = north + buf_y
|
||||
|
||||
if z <= 7:
|
||||
limit = 5000
|
||||
limit = 3000
|
||||
elif z <= 9:
|
||||
limit = 25000
|
||||
limit = 8000
|
||||
elif z <= 11:
|
||||
limit = 25000
|
||||
limit = 15000
|
||||
else:
|
||||
limit = 25000
|
||||
|
||||
# Минимальная длина трека по зуму — фильтруем мусор на низких зумах
|
||||
if z <= 7:
|
||||
min_length = 2000
|
||||
elif z == 8:
|
||||
min_length = 500
|
||||
elif z == 9:
|
||||
min_length = 200
|
||||
elif z == 10:
|
||||
min_length = 50
|
||||
else:
|
||||
min_length = 0
|
||||
|
||||
try:
|
||||
conn = get_db()
|
||||
cur = conn.cursor()
|
||||
@@ -269,8 +281,9 @@ async def get_tile(z: int, x: int, y: int):
|
||||
FROM trails
|
||||
WHERE min_lon <= ? AND max_lon >= ?
|
||||
AND min_lat <= ? AND max_lat >= ?
|
||||
AND (length_m >= ? OR length_m IS NULL)
|
||||
LIMIT ?
|
||||
""", (q_east, q_west, q_north, q_south, limit))
|
||||
""", (q_east, q_west, q_north, q_south, min_length, limit))
|
||||
trails_rows = cur.fetchall()
|
||||
|
||||
cur.execute("""
|
||||
|
||||
Reference in New Issue
Block a user