aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data_extractor/data_extractor.lua2
-rw-r--r--src/db_handler.py8
-rw-r--r--src/shop_map_node5_net.py10
-rw-r--r--src/static/icons/365discount.pngbin0 -> 669 bytes
-rw-r--r--src/static/icons/Brugsen.pngbin0 -> 354 bytes
-rw-r--r--src/static/icons/Dagli'Brugsen.pngbin0 -> 285 bytes
-rw-r--r--src/static/icons/Føtex Food.pngbin0 -> 559 bytes
-rw-r--r--src/static/icons/Føtex.pngbin0 -> 556 bytes
-rw-r--r--src/static/icons/Kvickly.pngbin0 -> 437 bytes
-rw-r--r--src/static/icons/Lidl.pngbin0 -> 756 bytes
-rw-r--r--src/static/icons/Løvbjerg.pngbin0 -> 356 bytes
-rw-r--r--src/static/icons/Meny.pngbin0 -> 505 bytes
-rw-r--r--src/static/icons/Min Købmand.pngbin0 -> 260 bytes
-rw-r--r--src/static/icons/Netto.pngbin0 -> 754 bytes
-rw-r--r--src/static/icons/Rema 1000.pngbin0 -> 814 bytes
-rw-r--r--src/static/icons/Spar.pngbin0 -> 803 bytes
-rw-r--r--src/static/icons/SuperBrugsen.pngbin0 -> 423 bytes
-rw-r--r--src/static/icons/Unknown.pngbin0 -> 296 bytes
-rw-r--r--src/static/images/marker-icon.pngbin1466 -> 0 bytes
-rw-r--r--src/static/images/marker-shadow.pngbin618 -> 0 bytes
-rw-r--r--src/static/main.js50
21 files changed, 61 insertions, 9 deletions
diff --git a/data_extractor/data_extractor.lua b/data_extractor/data_extractor.lua
index 8a95e6c..4732f3b 100644
--- a/data_extractor/data_extractor.lua
+++ b/data_extractor/data_extractor.lua
@@ -5,6 +5,7 @@ local shop = osm2pgsql.define_table({
{ column = 'name' },
{ column = 'class', not_null = true },
{ column = 'subclass' },
+ { column = 'brand' },
{ column = 'geom', type = 'point', not_null = true },
}})
@@ -17,6 +18,7 @@ function process_poi(object, geom)
if object.tags.shop then
a.class = 'shop'
a.subclass = object.tags.shop
+ a.brand = object.tags.brand
else
return
end
diff --git a/src/db_handler.py b/src/db_handler.py
index 565819d..3f77366 100644
--- a/src/db_handler.py
+++ b/src/db_handler.py
@@ -11,9 +11,10 @@ def get_supermarkets() -> (list[dict], list[str]):
with psycopg.connect(**db_con_params, row_factory=psycopg.rows.dict_row) as conn:
with conn.cursor() as cur:
cur.execute("""
- SELECT osm_type, osm_id, name,
+ SELECT name,
+ CASE WHEN brand ILIKE '%365%' THEN '365discount' ELSE BRAND END,
ST_Y(ST_Transform(geom, 4326)) AS lat, ST_X(ST_Transform(geom, 4326)) AS long
- FROM shop WHERE subclass = 'supermarket' AND name='Løvbjerg';
+ FROM shop WHERE subclass = 'supermarket';
""")
supermarkets = cur.fetchall()
@@ -26,8 +27,7 @@ def voronoi_polygons() -> (list[dict], list[str]):
cur.execute("""
SELECT ST_AsGeoJSON(ST_Transform(ST_VoronoiPolygons(ST_Collect(geom)), 4326)) as geojson
FROM shop
- WHERE subclass = 'supermarket'
- AND name = 'Løvbjerg';
+ WHERE subclass = 'supermarket';
""")
voronoi_polygons = cur.fetchone()['geojson']
diff --git a/src/shop_map_node5_net.py b/src/shop_map_node5_net.py
index 5154a0d..eafad5c 100644
--- a/src/shop_map_node5_net.py
+++ b/src/shop_map_node5_net.py
@@ -1,10 +1,10 @@
import json
+import os
import flask
import db_handler
-
app = flask.Flask(__name__, template_folder='templates', static_folder='static', static_url_path='')
@@ -13,6 +13,14 @@ def index():
return flask.redirect('/index.html')
+@app.route("/chains")
+def chains():
+ icons = os.listdir(os.path.join(os.getcwd(), 'src', 'static', 'icons'))
+ icons.pop(icons.index('Unknown.png'))
+ chains = [os.path.splitext(a)[0] for a in icons]
+ return json.dumps(chains)
+
+
@app.route("/supermarkets.json")
def supermarkets():
return db_handler.get_supermarkets()
diff --git a/src/static/icons/365discount.png b/src/static/icons/365discount.png
new file mode 100644
index 0000000..afc5c5b
--- /dev/null
+++ b/src/static/icons/365discount.png
Binary files differ
diff --git a/src/static/icons/Brugsen.png b/src/static/icons/Brugsen.png
new file mode 100644
index 0000000..5a36aa1
--- /dev/null
+++ b/src/static/icons/Brugsen.png
Binary files differ
diff --git a/src/static/icons/Dagli'Brugsen.png b/src/static/icons/Dagli'Brugsen.png
new file mode 100644
index 0000000..854c686
--- /dev/null
+++ b/src/static/icons/Dagli'Brugsen.png
Binary files differ
diff --git a/src/static/icons/Føtex Food.png b/src/static/icons/Føtex Food.png
new file mode 100644
index 0000000..6b0711a
--- /dev/null
+++ b/src/static/icons/Føtex Food.png
Binary files differ
diff --git a/src/static/icons/Føtex.png b/src/static/icons/Føtex.png
new file mode 100644
index 0000000..86c3f60
--- /dev/null
+++ b/src/static/icons/Føtex.png
Binary files differ
diff --git a/src/static/icons/Kvickly.png b/src/static/icons/Kvickly.png
new file mode 100644
index 0000000..81e3fee
--- /dev/null
+++ b/src/static/icons/Kvickly.png
Binary files differ
diff --git a/src/static/icons/Lidl.png b/src/static/icons/Lidl.png
new file mode 100644
index 0000000..f80f7f8
--- /dev/null
+++ b/src/static/icons/Lidl.png
Binary files differ
diff --git a/src/static/icons/Løvbjerg.png b/src/static/icons/Løvbjerg.png
new file mode 100644
index 0000000..6549a3e
--- /dev/null
+++ b/src/static/icons/Løvbjerg.png
Binary files differ
diff --git a/src/static/icons/Meny.png b/src/static/icons/Meny.png
new file mode 100644
index 0000000..5496f23
--- /dev/null
+++ b/src/static/icons/Meny.png
Binary files differ
diff --git a/src/static/icons/Min Købmand.png b/src/static/icons/Min Købmand.png
new file mode 100644
index 0000000..55bad2a
--- /dev/null
+++ b/src/static/icons/Min Købmand.png
Binary files differ
diff --git a/src/static/icons/Netto.png b/src/static/icons/Netto.png
new file mode 100644
index 0000000..50a8001
--- /dev/null
+++ b/src/static/icons/Netto.png
Binary files differ
diff --git a/src/static/icons/Rema 1000.png b/src/static/icons/Rema 1000.png
new file mode 100644
index 0000000..e73b99a
--- /dev/null
+++ b/src/static/icons/Rema 1000.png
Binary files differ
diff --git a/src/static/icons/Spar.png b/src/static/icons/Spar.png
new file mode 100644
index 0000000..cc88bb6
--- /dev/null
+++ b/src/static/icons/Spar.png
Binary files differ
diff --git a/src/static/icons/SuperBrugsen.png b/src/static/icons/SuperBrugsen.png
new file mode 100644
index 0000000..d7e6e88
--- /dev/null
+++ b/src/static/icons/SuperBrugsen.png
Binary files differ
diff --git a/src/static/icons/Unknown.png b/src/static/icons/Unknown.png
new file mode 100644
index 0000000..4209ecf
--- /dev/null
+++ b/src/static/icons/Unknown.png
Binary files differ
diff --git a/src/static/images/marker-icon.png b/src/static/images/marker-icon.png
deleted file mode 100644
index 950edf2..0000000
--- a/src/static/images/marker-icon.png
+++ /dev/null
Binary files differ
diff --git a/src/static/images/marker-shadow.png b/src/static/images/marker-shadow.png
deleted file mode 100644
index 9fd2979..0000000
--- a/src/static/images/marker-shadow.png
+++ /dev/null
Binary files differ
diff --git a/src/static/main.js b/src/static/main.js
index 24d0edf..405f455 100644
--- a/src/static/main.js
+++ b/src/static/main.js
@@ -4,15 +4,46 @@ L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
+let known_store_chains;
+let icons = {};
+
+async function fetchChains() {
+ const response = await fetch("chains");
+ known_store_chains = await response.json();
+
+ icons["Unknown"] = L.icon({
+ iconUrl: 'icons/Unknown.png',
+ iconSize: [10, 16],
+ iconAnchor: [16, 16],
+ });
+
+ for (let known_store_chain of known_store_chains) {
+ icons[known_store_chain] = L.icon({
+ iconUrl: `icons/${known_store_chain}.png`,
+ iconAnchor: [8, 8],
+ });
+ }
+
+ fetchShops();
+}
function addMarker(shop) {
- L.marker([shop.lat, shop.long], {title: shop.name, }).addTo(map);
+ let icon;
+
+ if (known_store_chains.includes(shop.brand)){
+ icon = icons[shop.brand];
+ } else {
+ icon = icons["Unknown"];
+ }
+
+ L.marker([shop.lat, shop.long], {
+ title: shop.name,
+ icon: icon,
+ }).addTo(map);
}
function addPolygon(polygon) {
L.polygon(polygon, {color: 'red'}).addTo(map);
-
- console.log(polygon.coordinates)
}
@@ -22,11 +53,22 @@ async function fetchShops() {
shops.forEach((shop) => addMarker(shop));
}
-fetchShops()
async function fetch_voronoi_polygons() {
const response = await fetch("voronoi_polygons.json");
const voronoi_polygons = await response.json();
voronoi_polygons.forEach((polygon) => addPolygon(polygon));
}
+
+function update(){
+ if (map.getZoom() >= 14){
+ //console.log('update')
+ }
+}
+
+map.on('moveend', function() {
+ update()
+});
+
+fetchChains()
fetch_voronoi_polygons() \ No newline at end of file