goodmap 0.4.3__py3-none-any.whl → 0.4.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
goodmap/core.py CHANGED
@@ -1,3 +1,5 @@
1
+ from typing import Any, Dict, List
2
+
1
3
  # TODO move filtering to db site
2
4
 
3
5
 
@@ -10,10 +12,35 @@ def does_fulfill_requirement(entry, requirements):
10
12
  return all(matches)
11
13
 
12
14
 
15
+ def sort_by_distance(data: List[Dict[str, Any]], query_params: Dict[str, List[str]]):
16
+ try:
17
+ if "lat" in query_params and "lon" in query_params:
18
+ lat = float(query_params["lat"][0])
19
+ lon = float(query_params["lon"][0])
20
+ data.sort(key=lambda x: (x["position"][0] - lat) ** 2 + (x["position"][1] - lon) ** 2)
21
+ return data
22
+ return data
23
+ except (ValueError, KeyError, IndexError):
24
+ return data
25
+
26
+
27
+ def limit(data, query_params):
28
+ try:
29
+ if "limit" in query_params:
30
+ limit = int(query_params["limit"][0])
31
+ data = data[:limit]
32
+ return data
33
+ return data
34
+ except (ValueError, KeyError, IndexError):
35
+ return data
36
+
37
+
13
38
  def get_queried_data(all_data, categories, query_params):
14
39
  requirements = []
15
40
  for key in categories.keys():
16
41
  requirements.append((key, query_params.get(key)))
17
42
 
18
43
  filtered_data = [x for x in all_data if does_fulfill_requirement(x, requirements)]
19
- return filtered_data
44
+ final_data = sort_by_distance(filtered_data, query_params)
45
+ final_data = limit(final_data, query_params)
46
+ return final_data
@@ -116,6 +116,7 @@ window.PRIMARY_COLOR = "{{ primary_color }}";
116
116
  window.SHOW_SUGGEST_NEW_POINT_BUTTON = {{ feature_flags.SHOW_SUGGEST_NEW_POINT_BUTTON | default(false) | tojson }};
117
117
  window.SHOW_SEARCH_BAR = {{ feature_flags.SHOW_SEARCH_BAR | default(false) | tojson }};
118
118
  window.USE_LAZY_LOADING = {{ feature_flags.USE_LAZY_LOADING | default(false) | tojson }};
119
+ window.SHOW_ACCESSIBILITY_TABLE = {{ feature_flags.SHOW_ACCESSIBILITY_TABLE | default(false) | tojson }};
119
120
  </script>
120
121
  <script src="/static/map.js"></script>
121
122
  {% endblock %}
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: goodmap
3
- Version: 0.4.3
3
+ Version: 0.4.4
4
4
  Summary: Map engine to serve all the people :)
5
5
  Author: Krzysztof Kolodzinski
6
6
  Author-email: krzysztof.kolodzinski@problematy.pl
@@ -1,5 +1,5 @@
1
1
  goodmap/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2
- goodmap/core.py,sha256=hOTHrDRzbqkfSeKAoD01lzSoY4W8JwupXlJTwTzcvAU,586
2
+ goodmap/core.py,sha256=rzMhOIYnR1jxTX6uHQJKIPLYxdUm4_v2d6LrtHtJpHU,1465
3
3
  goodmap/core_api.py,sha256=wy861bym-OtJV_y65TNJNr_hxUW45bUK0j2Vt96HG1s,6544
4
4
  goodmap/data_models/location.py,sha256=ESR4Z_zINIjldJKhlXImMaQrdtUPJBQc6SatpPPJyNQ,1054
5
5
  goodmap/data_validator.py,sha256=e_PCc2CTgiEBK6inF_HDX5mb5R8poh3KkcbhyrLrFVA,4086
@@ -7,8 +7,8 @@ goodmap/db.py,sha256=AJHUP3n29BRjgt6GoGnPtxLNg5TL-KSJhtSZtsZKmGM,3665
7
7
  goodmap/formatter.py,sha256=VlUHcK1HtM_IEU0VE3S5TOkZLVheMdakvUeW2tCKdq0,783
8
8
  goodmap/goodmap.py,sha256=cPTTyGqajuza3RDlfFuCl8idxy7TFo6LPuANP8hmg7U,1806
9
9
  goodmap/templates/admin.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- goodmap/templates/map.html,sha256=eU_h61l404g8e3_wszUokDrOC92bQ1nFl8yGMKRXFww,3820
11
- goodmap-0.4.3.dist-info/LICENSE.md,sha256=nkCQOR7uheLRvHRfXmwx9LhBnMcPeBU9d4ebLojDiQU,1067
12
- goodmap-0.4.3.dist-info/METADATA,sha256=nvPI8Jtcm5s-KrGCABgU5OKgYEui4gjC5B-MKgg26tU,4525
13
- goodmap-0.4.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
14
- goodmap-0.4.3.dist-info/RECORD,,
10
+ goodmap/templates/map.html,sha256=llzzfWGHM0Xtr4Io05QJLCLajySHNBzKejR0Km5nGMw,3926
11
+ goodmap-0.4.4.dist-info/LICENSE.md,sha256=nkCQOR7uheLRvHRfXmwx9LhBnMcPeBU9d4ebLojDiQU,1067
12
+ goodmap-0.4.4.dist-info/METADATA,sha256=9efllxXa6i44w0t6sXK5ok5mNsNDtmcxh_OolIBfdSg,4525
13
+ goodmap-0.4.4.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
14
+ goodmap-0.4.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: poetry-core 2.0.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any