Compare commits
11 commits
88b14b434e
...
8c44ac56e6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c44ac56e6 | ||
|
|
89ca5851b8 | ||
|
|
dcd221c096 | ||
|
|
7109190f80 | ||
|
|
1b280827ea | ||
|
|
2edce7c73a | ||
|
|
dd038072c9 | ||
|
|
fd2faa3661 | ||
|
|
913b558ebf | ||
|
|
bafd1cb196 | ||
|
|
4b2dca7bb3 |
8 changed files with 90 additions and 39 deletions
22
engine.py
22
engine.py
|
|
@ -6,7 +6,7 @@ import overpy
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import scipy
|
import scipy
|
||||||
# import random
|
import random
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
@ -19,12 +19,12 @@ BRANDS: dict[str, str] = {
|
||||||
CACHE_FOLDER = Path(".cache")
|
CACHE_FOLDER = Path(".cache")
|
||||||
|
|
||||||
LOCS_COUNT = 5
|
LOCS_COUNT = 5
|
||||||
DISTS_COUNT = 5
|
DISTS_COUNT = 2
|
||||||
|
|
||||||
FORMAT_FACTOR = 1e6 # μm
|
FORMAT_FACTOR = 1e3 # μm
|
||||||
FIRST_SEP = ':'
|
FIRST_SEP = ':'
|
||||||
OTHER_SEP = ','
|
OTHER_SEP = ','
|
||||||
LOC_SEP = ';'
|
LOC_SEP = '; '
|
||||||
|
|
||||||
cached_dists = {}
|
cached_dists = {}
|
||||||
cached_series = {}
|
cached_series = {}
|
||||||
|
|
@ -137,17 +137,25 @@ def trilaterate(stations: list[StationT], disp: bool = False) -> tuple[float, fl
|
||||||
Each station is of the format ((lat, lon), distance).
|
Each station is of the format ((lat, lon), distance).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
best_err = None
|
||||||
|
best = (0., 0.)
|
||||||
|
|
||||||
|
for pos, _ in stations:
|
||||||
res = scipy.optimize.minimize(
|
res = scipy.optimize.minimize(
|
||||||
lambda pos: trilat_error(stations, pos),
|
lambda pos: trilat_error(stations, pos),
|
||||||
# stations[0][0],
|
# stations[0][0],
|
||||||
(0.0, 0.0),
|
pos,
|
||||||
method='Nelder-Mead',
|
method='Nelder-Mead',
|
||||||
)
|
)
|
||||||
|
|
||||||
if not res.success:
|
if not res.success:
|
||||||
print("WARNING: Optimisation failed.")
|
continue
|
||||||
|
|
||||||
return res.x
|
if best_err is None or res.fun < best_err:
|
||||||
|
best = res.x
|
||||||
|
best_err = res.fun
|
||||||
|
|
||||||
|
return best
|
||||||
|
|
||||||
|
|
||||||
def encode_greggs(loc: int) -> list[float]:
|
def encode_greggs(loc: int) -> list[float]:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from engine import encode_greggs, decode_greggs, encode, decode, format_location, parse_location, spherical_dist, fetch_data
|
from engine import encode_greggs, decode_greggs, encode, decode, format_location, parse_location, spherical_dist, fetch_data, format_dist, parse_dist
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import time
|
import time
|
||||||
|
|
@ -62,8 +62,11 @@ def test_encode_decode_greggs():
|
||||||
encoded = encode_greggs(i)
|
encoded = encode_greggs(i)
|
||||||
# tqdm.write(f"Encoding took {time.monotonic() - t:.3f}s")
|
# 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()
|
# t = time.monotonic()
|
||||||
decoded = decode_greggs(encoded)
|
decoded = decode_greggs(parsed)
|
||||||
# tqdm.write(f"Decoding took {time.monotonic() - t:.3f}s")
|
# tqdm.write(f"Decoding took {time.monotonic() - t:.3f}s")
|
||||||
|
|
||||||
if i != decoded:
|
if i != decoded:
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
src:
|
src:
|
||||||
url('/static/font/CynthoNextBold.otf') format('opentype');
|
url('/static/font/CynthoNextBold.otf') format('opentype');
|
||||||
|
|
||||||
font-weight: normal;
|
font-weight: bold;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -16,11 +16,20 @@
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'CynthoExtraLight';
|
||||||
|
src:
|
||||||
|
url('/static/font/CynthoNextExtraLight.otf') format('opentype');
|
||||||
|
|
||||||
|
font-weight: 900;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
/* This sets the font color for all text */
|
/* This sets the font color for all text */
|
||||||
body {
|
body {
|
||||||
background-color:rgba(250, 184, 0);
|
background-color:rgba(250, 184, 0);
|
||||||
color: #006cab;
|
color: #006cab;
|
||||||
font-size: 20px;
|
font-size: 25px;
|
||||||
font-family: "CynthoRegular", sans-serif;;
|
font-family: "CynthoRegular", sans-serif;;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
@ -30,7 +39,7 @@ body {
|
||||||
button {
|
button {
|
||||||
background-color: rgba(0, 108, 171);
|
background-color: rgba(0, 108, 171);
|
||||||
color: rgba(250, 184, 0);
|
color: rgba(250, 184, 0);
|
||||||
font-size: 20px;
|
font-size: 30px;
|
||||||
font-family: "CynthoRegular", sans-serif;
|
font-family: "CynthoRegular", sans-serif;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 25px 25px;
|
padding: 25px 25px;
|
||||||
|
|
@ -47,11 +56,11 @@ button {
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
width: 80%;
|
width: 800px;;
|
||||||
height: 300px;
|
height: 300px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border: 4px solid rgba(0, 108, 171);
|
border: 3px solid rgba(0, 108, 171);
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
background-color: rgb(255, 199, 44);
|
background-color: rgb(255, 199, 44);
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
|
|
@ -64,10 +73,19 @@ textarea {
|
||||||
display: flex; /* places buttons side-by-side */
|
display: flex; /* places buttons side-by-side */
|
||||||
justify-content: center; /* centers them horizontally */ /* aligns vertically */
|
justify-content: center; /* centers them horizontally */ /* aligns vertically */
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
margin-top: 10px;
|
margin-top: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
|
display: block;
|
||||||
|
margin: 0 auto;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 80%;
|
width: 650px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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 */
|
||||||
}
|
}
|
||||||
BIN
websiteapp/static/img/logo_1.png
Normal file
BIN
websiteapp/static/img/logo_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
|
|
@ -17,10 +17,20 @@
|
||||||
<body>
|
<body>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<h1 style="color:#ffffff ; margin-top: 20px; margin-bottom: 10px;
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="image">
|
||||||
|
<img src="{% static 'img/logo_1.png' %}" alt="cute logo" style="width:60px;height:60px;">
|
||||||
|
</div>
|
||||||
|
<div class="text">
|
||||||
|
<h1 style="color:#ffffff; font-size: 60px; margin-top: 20px; margin-bottom: 10px; font-family:CynthoRegular; font-weight: bold;
|
||||||
letter-spacing: 1.5px;" >
|
letter-spacing: 1.5px;" >
|
||||||
GREGGordinates
|
GREGGordinates
|
||||||
</h1>
|
</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<p> "Everything is relative to greggs, and only that is absolute." </p>
|
<p> "Everything is relative to greggs, and only that is absolute." </p>
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,10 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<a href="{% url 'decode' %}">
|
||||||
|
<button>
|
||||||
|
←
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,13 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div width="100%">
|
<div width="100%">
|
||||||
<p width="80%" style="border-radius: 10px; border: 1px solid black; background-color: rgba(192, 192, 192, 0.5); max-width: 500px; margin: 0 auto; padding: 20px; word-wrap:break-word;"> {{ result }} </p>
|
<p width="80%" style="border-radius: 10px; border: 3px solid rgba(0, 108, 171); background-color: rgb(255, 199, 44); max-width: 500px; margin: 0 auto; padding: 20px; word-wrap:break-word;"> {{ result }} </p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<a href="{% url 'encode' %}">
|
||||||
|
<button>
|
||||||
|
←
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<br><br>
|
||||||
<img src="{% static 'img/drawing.png' %}" alt="Cute map drawing" id="homepageimage">
|
<img src="{% static 'img/drawing.png' %}" alt="Cute map drawing">
|
||||||
|
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<a href="{% url 'encode' %}">
|
<a href="{% url 'encode' %}">
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
display: flex; /* places buttons side-by-side */
|
display: flex; /* places buttons side-by-side */
|
||||||
justify-content: center; /* centers them horizontally */
|
justify-content: center; /* centers them horizontally */
|
||||||
align-items: center; /* aligns vertically */
|
align-items: center; /* aligns vertically */
|
||||||
gap: 30px;
|
gap: 40px;
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-group button {
|
.btn-group button {
|
||||||
padding: 40px 40px;
|
padding: 30px 50px;
|
||||||
font-size:25px;
|
font-size:25px;
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue