Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reduce grid svg file size #535

Merged
merged 1 commit into from
Oct 29, 2023
Merged
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
6 changes: 5 additions & 1 deletion run_page/gpxtrackposter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ def project(
scale = size.x / d_x if size.x / size.y <= d_x / d_y else size.y / d_y
offset = offset + 0.5 * (size - scale * XY(d_x, -d_y)) - scale * XY(min_x, min_y)
lines = []
# If len > $zoom_threshold, choose 1 point out of every $step to reduce size of the SVG file
zoom_threshold = 400
for latlngline in latlnglines:
line = []
for latlng in latlngline:
step = int(len(latlngline) / zoom_threshold) + 1
for i in range(0, len(latlngline), step):
latlng = latlngline[i]
if bbox.contains(latlng):
line.append((offset + scale * latlng2xy(latlng)).tuple())
else:
Expand Down