Merge branch 'main' into website
This commit is contained in:
commit
e9d3355fe7
1 changed files with 12 additions and 2 deletions
14
engine.py
14
engine.py
|
|
@ -7,7 +7,7 @@ BRANDS: dict[str, str] = {
|
||||||
"greggs": "[\"brand:wikidata\"=\"Q3403981\"]",
|
"greggs": "[\"brand:wikidata\"=\"Q3403981\"]",
|
||||||
}
|
}
|
||||||
|
|
||||||
EncodedLocation = list[float, list[float]]
|
EncodedLocation = list[tuple[float, list[float]]]
|
||||||
|
|
||||||
|
|
||||||
def fetch_data(brand: str) -> list[tuple[float | None, float | None]]:
|
def fetch_data(brand: str) -> list[tuple[float | None, float | None]]:
|
||||||
|
|
@ -36,7 +36,10 @@ def encode(location: tuple[float, float]) -> EncodedLocation:
|
||||||
"""Encode a location."""
|
"""Encode a location."""
|
||||||
|
|
||||||
# Stub
|
# Stub
|
||||||
return []
|
return [
|
||||||
|
(5., [1., 2., 3.]),
|
||||||
|
(6., [4., 5., 6.]),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def decode(location: EncodedLocation) -> tuple[float, float]:
|
def decode(location: EncodedLocation) -> tuple[float, float]:
|
||||||
|
|
@ -46,12 +49,19 @@ def decode(location: EncodedLocation) -> tuple[float, float]:
|
||||||
return (0.091659, 52.210796)
|
return (0.091659, 52.210796)
|
||||||
|
|
||||||
|
|
||||||
|
def format_location(location: EncodedLocation) -> str:
|
||||||
|
"""Format an encoded location as a string."""
|
||||||
|
return ";".join([f"{a}:{','.join(map(str, b))}" for (a, b) in location])
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Testing."""
|
"""Testing."""
|
||||||
print("Running query...")
|
print("Running query...")
|
||||||
greggs = fetch_data("greggs")
|
greggs = fetch_data("greggs")
|
||||||
print(f"Query done - got {len(greggs)} Greggs!")
|
print(f"Query done - got {len(greggs)} Greggs!")
|
||||||
|
|
||||||
|
print(format_location(encode((0.091659, 52.210796))))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue