Spaces:
Sleeping
Sleeping
Commit
·
69a1ff7
1
Parent(s):
35f2f48
stuff
Browse files
app/data_processing/data_provider.py
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
from data_processing.get_smallAreaInfo import get_smallAreas
|
2 |
from data_processing.point_scoring import score_current
|
3 |
from data_processing.get_station_coverage import get_station_coverage
|
@@ -15,6 +18,8 @@ class Data_provider():
|
|
15 |
self.transformer_to_3057 = Transformer.from_crs("EPSG:4326", "EPSG:3057", always_xy=True)
|
16 |
self.transformer_to_4326 = Transformer.from_crs("EPSG:3057", "EPSG:4326", always_xy=True)
|
17 |
|
|
|
|
|
18 |
def get_station_score(self, station_coord, w_density=1, w_income=1, w_age=1, radius=400, EPSG_4326=True):
|
19 |
"""
|
20 |
Calculate the score for a station based on the given weights and radius.
|
@@ -78,6 +83,10 @@ class Data_provider():
|
|
78 |
"""
|
79 |
return self.transformer_to_4326.transform(*station_coord)
|
80 |
|
|
|
|
|
|
|
|
|
81 |
|
82 |
|
83 |
|
@@ -86,7 +95,7 @@ if __name__ == '__main__':
|
|
86 |
dummy_coord2 = (-21.910388, 64.144947) # EPSG:4326 coordinates
|
87 |
dummy_coord3 = (358374.26032876654, 407938.72289760906) # ISN93/Lambert
|
88 |
# dummy_coord3 =
|
89 |
-
backend =
|
90 |
print("dummy_coord1: ", backend.get_station_score(dummy_coord1, EPSG_4326=False))
|
91 |
print("dummy_coord2: ", backend.get_station_score(dummy_coord2))
|
92 |
print("dummy_coord3: ", backend.get_station_score(dummy_coord3, EPSG_4326=False))
|
|
|
1 |
+
from typing import List, Tuple
|
2 |
+
|
3 |
+
from traitlets import Float
|
4 |
from data_processing.get_smallAreaInfo import get_smallAreas
|
5 |
from data_processing.point_scoring import score_current
|
6 |
from data_processing.get_station_coverage import get_station_coverage
|
|
|
18 |
self.transformer_to_3057 = Transformer.from_crs("EPSG:4326", "EPSG:3057", always_xy=True)
|
19 |
self.transformer_to_4326 = Transformer.from_crs("EPSG:3057", "EPSG:4326", always_xy=True)
|
20 |
|
21 |
+
|
22 |
+
|
23 |
def get_station_score(self, station_coord, w_density=1, w_income=1, w_age=1, radius=400, EPSG_4326=True):
|
24 |
"""
|
25 |
Calculate the score for a station based on the given weights and radius.
|
|
|
83 |
"""
|
84 |
return self.transformer_to_4326.transform(*station_coord)
|
85 |
|
86 |
+
def total_score(self, stations_coordinates: List[Tuple[Float]], w_density=1, w_income=1, w_age=1, radius=400, EPSG_4326=True):
|
87 |
+
scores = []
|
88 |
+
for coord in stations_coordinates:
|
89 |
+
score = self.get_station_scores(coord) - get_penalty()
|
90 |
|
91 |
|
92 |
|
|
|
95 |
dummy_coord2 = (-21.910388, 64.144947) # EPSG:4326 coordinates
|
96 |
dummy_coord3 = (358374.26032876654, 407938.72289760906) # ISN93/Lambert
|
97 |
# dummy_coord3 =
|
98 |
+
backend = Data_provider()
|
99 |
print("dummy_coord1: ", backend.get_station_score(dummy_coord1, EPSG_4326=False))
|
100 |
print("dummy_coord2: ", backend.get_station_score(dummy_coord2))
|
101 |
print("dummy_coord3: ", backend.get_station_score(dummy_coord3, EPSG_4326=False))
|