diff --git a/engine.py b/engine.py index 72b3bf6..cf5da69 100755 --- a/engine.py +++ b/engine.py @@ -6,7 +6,7 @@ import overpy import numpy as np import pandas as pd import scipy -import random +# import random from pathlib import Path @@ -19,12 +19,12 @@ BRANDS: dict[str, str] = { CACHE_FOLDER = Path(".cache") LOCS_COUNT = 5 -DISTS_COUNT = 2 +DISTS_COUNT = 5 -FORMAT_FACTOR = 1e3 # μm +FORMAT_FACTOR = 1e6 # μm FIRST_SEP = ':' OTHER_SEP = ',' -LOC_SEP = '; ' +LOC_SEP = ';' cached_dists = {} cached_series = {} @@ -137,25 +137,17 @@ def trilaterate(stations: list[StationT], disp: bool = False) -> tuple[float, fl Each station is of the format ((lat, lon), distance). """ - best_err = None - best = (0., 0.) + res = scipy.optimize.minimize( + lambda pos: trilat_error(stations, pos), + # stations[0][0], + (0.0, 0.0), + method='Nelder-Mead', + ) - for pos, _ in stations: - res = scipy.optimize.minimize( - lambda pos: trilat_error(stations, pos), - # stations[0][0], - pos, - method='Nelder-Mead', - ) + if not res.success: + print("WARNING: Optimisation failed.") - if not res.success: - continue - - if best_err is None or res.fun < best_err: - best = res.x - best_err = res.fun - - return best + return res.x def encode_greggs(loc: int) -> list[float]: diff --git a/engine_test.py b/engine_test.py index 70a7b38..8441ef9 100755 --- a/engine_test.py +++ b/engine_test.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from engine import encode_greggs, decode_greggs, encode, decode, format_location, parse_location, spherical_dist, fetch_data, format_dist, parse_dist +from engine import encode_greggs, decode_greggs, encode, decode, format_location, parse_location, spherical_dist, fetch_data from tqdm import tqdm import numpy as np import time @@ -62,11 +62,8 @@ def test_encode_decode_greggs(): encoded = encode_greggs(i) # tqdm.write(f"Encoding took {time.monotonic() - t:.3f}s") - stringified = ",".join(map(format_dist, encoded)) - parsed = [parse_dist(s.strip()) for s in stringified.split(",")] - # t = time.monotonic() - decoded = decode_greggs(parsed) + decoded = decode_greggs(encoded) # tqdm.write(f"Decoding took {time.monotonic() - t:.3f}s") if i != decoded: diff --git a/websiteapp/static/css/styles.css b/websiteapp/static/css/styles.css index ffadc10..976497d 100644 --- a/websiteapp/static/css/styles.css +++ b/websiteapp/static/css/styles.css @@ -1,27 +1,18 @@ @font-face { font-family: 'CynthoBold'; - src: + src: url('/static/font/CynthoNextBold.otf') format('opentype'); - font-weight: bold; - font-style: normal; -} - -@font-face { - font-family: 'CynthoRegular'; - src: - url('/static/font/CynthoNextRegular.otf') format('opentype'); - font-weight: normal; font-style: normal; } @font-face { - font-family: 'CynthoExtraLight'; - src: - url('/static/font/CynthoNextExtraLight.otf') format('opentype'); + font-family: 'CynthoRegular'; + src: + url('/static/font/CynthoNextRegular.otf') format('opentype'); - font-weight: 900; + font-weight: normal; font-style: normal; } @@ -29,7 +20,7 @@ body { background-color:rgba(250, 184, 0); color: #006cab; - font-size: 25px; + font-size: 20px; font-family: "CynthoRegular", sans-serif;; margin: 0; padding: 0; @@ -39,7 +30,7 @@ body { button { background-color: rgba(0, 108, 171); color: rgba(250, 184, 0); - font-size: 30px; + font-size: 20px; font-family: "CynthoRegular", sans-serif; font-weight: bold; padding: 25px 25px; @@ -56,11 +47,11 @@ button { } textarea { - width: 800px;; + width: 80%; height: 300px; padding: 12px; box-sizing: border-box; - border: 3px solid rgba(0, 108, 171); + border: 4px solid rgba(0, 108, 171); border-radius: 5px; background-color: rgb(255, 199, 44); font-size: 18px; @@ -72,20 +63,11 @@ textarea { .btn-group { display: flex; /* places buttons side-by-side */ justify-content: center; /* centers them horizontally */ /* aligns vertically */ - gap: 15px; - margin-top: 0px; + gap: 15px; + margin-top: 10px; } img { - display: block; - margin: 0 auto; - align-items: center; - width: 650px; + align-items: center; + width: 80%; } - -.container { -display: flex; /* places items in a row */ -align-items: center; /* vertically centers image and text */ -justify-content: center; /* centers the whole thing horizontally */ -gap: 10px; /* space between image and text */ -} \ No newline at end of file diff --git a/websiteapp/static/img/logo_1.png b/websiteapp/static/img/logo_1.png deleted file mode 100644 index de1fdb6..0000000 Binary files a/websiteapp/static/img/logo_1.png and /dev/null differ diff --git a/websiteapp/templates/websiteapp/base.html b/websiteapp/templates/websiteapp/base.html index b31a614..8c44160 100644 --- a/websiteapp/templates/websiteapp/base.html +++ b/websiteapp/templates/websiteapp/base.html @@ -3,10 +3,10 @@
- + - +
- "Everything is relative to greggs, and only that is absolute."
{% block content %} diff --git a/websiteapp/templates/websiteapp/decode_result.html b/websiteapp/templates/websiteapp/decode_result.html index 6631287..0b863cc 100644 --- a/websiteapp/templates/websiteapp/decode_result.html +++ b/websiteapp/templates/websiteapp/decode_result.html @@ -35,10 +35,4 @@ document.addEventListener("DOMContentLoaded", function () { }); - - - - {% endblock %} diff --git a/websiteapp/templates/websiteapp/encode_result.html b/websiteapp/templates/websiteapp/encode_result.html index ba6abad..db93180 100644 --- a/websiteapp/templates/websiteapp/encode_result.html +++ b/websiteapp/templates/websiteapp/encode_result.html @@ -3,13 +3,7 @@ {% block content %}{{ result }}
+{{ result }}
+
+