geo-activity-playground 0.35.1__py3-none-any.whl → 0.36.1__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.
- geo_activity_playground/core/activities.py +21 -13
- geo_activity_playground/core/raster_map.py +9 -13
- geo_activity_playground/importers/directory.py +6 -15
- geo_activity_playground/webui/app.py +27 -35
- geo_activity_playground/webui/{auth/blueprint.py → auth_blueprint.py} +1 -1
- geo_activity_playground/webui/{eddington/controller.py → eddington_blueprint.py} +17 -13
- geo_activity_playground/webui/heatmap/blueprint.py +36 -10
- geo_activity_playground/webui/heatmap/heatmap_controller.py +142 -60
- geo_activity_playground/webui/heatmap/templates/heatmap/index.html.j2 +30 -12
- geo_activity_playground/webui/{search/blueprint.py → search_blueprint.py} +1 -1
- geo_activity_playground/webui/settings/blueprint.py +1 -2
- geo_activity_playground/webui/square_planner_blueprint.py +118 -0
- geo_activity_playground/webui/{summary/controller.py → summary_blueprint.py} +23 -23
- geo_activity_playground/webui/templates/page.html.j2 +17 -11
- geo_activity_playground/webui/tile_blueprint.py +42 -0
- geo_activity_playground/webui/upload_blueprint.py +1 -3
- {geo_activity_playground-0.35.1.dist-info → geo_activity_playground-0.36.1.dist-info}/METADATA +1 -1
- {geo_activity_playground-0.35.1.dist-info → geo_activity_playground-0.36.1.dist-info}/RECORD +26 -34
- geo_activity_playground/webui/eddington/__init__.py +0 -0
- geo_activity_playground/webui/eddington/blueprint.py +0 -16
- geo_activity_playground/webui/square_planner/__init__.py +0 -0
- geo_activity_playground/webui/square_planner/blueprint.py +0 -38
- geo_activity_playground/webui/square_planner/controller.py +0 -101
- geo_activity_playground/webui/summary/__init__.py +0 -0
- geo_activity_playground/webui/summary/blueprint.py +0 -14
- geo_activity_playground/webui/tile/__init__.py +0 -0
- geo_activity_playground/webui/tile/blueprint.py +0 -29
- geo_activity_playground/webui/tile/controller.py +0 -36
- /geo_activity_playground/webui/{auth/templates → templates}/auth/index.html.j2 +0 -0
- /geo_activity_playground/webui/{eddington/templates → templates}/eddington/index.html.j2 +0 -0
- /geo_activity_playground/webui/{search/templates → templates}/search/index.html.j2 +0 -0
- /geo_activity_playground/webui/{square_planner/templates → templates}/square_planner/index.html.j2 +0 -0
- /geo_activity_playground/webui/{summary/templates → templates}/summary/index.html.j2 +0 -0
- {geo_activity_playground-0.35.1.dist-info → geo_activity_playground-0.36.1.dist-info}/LICENSE +0 -0
- {geo_activity_playground-0.35.1.dist-info → geo_activity_playground-0.36.1.dist-info}/WHEEL +0 -0
- {geo_activity_playground-0.35.1.dist-info → geo_activity_playground-0.36.1.dist-info}/entry_points.txt +0 -0
@@ -1,101 +0,0 @@
|
|
1
|
-
import pickle
|
2
|
-
|
3
|
-
import geojson
|
4
|
-
|
5
|
-
from geo_activity_playground.core.activities import ActivityRepository
|
6
|
-
from geo_activity_playground.explorer.grid_file import make_explorer_rectangle
|
7
|
-
from geo_activity_playground.explorer.grid_file import make_explorer_tile
|
8
|
-
from geo_activity_playground.explorer.grid_file import make_grid_file_geojson
|
9
|
-
from geo_activity_playground.explorer.grid_file import make_grid_file_gpx
|
10
|
-
from geo_activity_playground.explorer.grid_file import make_grid_points
|
11
|
-
from geo_activity_playground.explorer.tile_visits import TileVisitAccessor
|
12
|
-
|
13
|
-
|
14
|
-
class SquarePlannerController:
|
15
|
-
def __init__(
|
16
|
-
self, repository: ActivityRepository, tile_visit_accessor: TileVisitAccessor
|
17
|
-
) -> None:
|
18
|
-
self._repository = repository
|
19
|
-
self._tile_visit_accessor = tile_visit_accessor
|
20
|
-
|
21
|
-
self._tile_visits = self._tile_visit_accessor.tile_state["tile_visits"]
|
22
|
-
|
23
|
-
def action_planner(
|
24
|
-
self, zoom: int, square_x: int, square_y: int, square_size: int
|
25
|
-
) -> dict:
|
26
|
-
square_geojson = geojson.dumps(
|
27
|
-
geojson.FeatureCollection(
|
28
|
-
features=[
|
29
|
-
make_explorer_rectangle(
|
30
|
-
square_x,
|
31
|
-
square_y,
|
32
|
-
square_x + square_size,
|
33
|
-
square_y + square_size,
|
34
|
-
zoom,
|
35
|
-
)
|
36
|
-
]
|
37
|
-
)
|
38
|
-
)
|
39
|
-
|
40
|
-
missing_geojson = geojson.dumps(
|
41
|
-
geojson.FeatureCollection(
|
42
|
-
features=[
|
43
|
-
make_explorer_tile(
|
44
|
-
tile_x,
|
45
|
-
tile_y,
|
46
|
-
{},
|
47
|
-
zoom,
|
48
|
-
)
|
49
|
-
for tile_x in range(square_x, square_x + square_size)
|
50
|
-
for tile_y in range(square_y, square_y + square_size)
|
51
|
-
if (tile_x, tile_y) not in self._get_explored_tiles(zoom)
|
52
|
-
]
|
53
|
-
)
|
54
|
-
)
|
55
|
-
|
56
|
-
return {
|
57
|
-
"explored_geojson": self._get_explored_geojson(zoom),
|
58
|
-
"missing_geojson": missing_geojson,
|
59
|
-
"square_geojson": square_geojson,
|
60
|
-
"zoom": zoom,
|
61
|
-
"square_x": square_x,
|
62
|
-
"square_y": square_y,
|
63
|
-
"square_size": square_size,
|
64
|
-
}
|
65
|
-
|
66
|
-
def export_missing_tiles(
|
67
|
-
self, zoom: int, square_x: int, square_y: int, square_size: int, suffix: str
|
68
|
-
) -> str:
|
69
|
-
points = make_grid_points(
|
70
|
-
(
|
71
|
-
(tile_x, tile_y)
|
72
|
-
for tile_x in range(square_x, square_x + square_size)
|
73
|
-
for tile_y in range(square_y, square_y + square_size)
|
74
|
-
if (tile_x, tile_y) not in self._get_explored_tiles(zoom)
|
75
|
-
),
|
76
|
-
zoom,
|
77
|
-
)
|
78
|
-
if suffix == "geojson":
|
79
|
-
return make_grid_file_geojson(points)
|
80
|
-
elif suffix == "gpx":
|
81
|
-
return make_grid_file_gpx(points)
|
82
|
-
else:
|
83
|
-
raise RuntimeError(f"Unsupported suffix {suffix}.")
|
84
|
-
|
85
|
-
def _get_explored_tiles(self, zoom: int) -> set[tuple[int, int]]:
|
86
|
-
return set(self._tile_visits[zoom].keys())
|
87
|
-
|
88
|
-
def _get_explored_geojson(self, zoom: int) -> str:
|
89
|
-
return geojson.dumps(
|
90
|
-
geojson.FeatureCollection(
|
91
|
-
features=[
|
92
|
-
make_explorer_tile(
|
93
|
-
tile_x,
|
94
|
-
tile_y,
|
95
|
-
{},
|
96
|
-
zoom,
|
97
|
-
)
|
98
|
-
for tile_x, tile_y in self._tile_visits[zoom].keys()
|
99
|
-
]
|
100
|
-
)
|
101
|
-
)
|
File without changes
|
@@ -1,14 +0,0 @@
|
|
1
|
-
from flask import Blueprint
|
2
|
-
from flask import render_template
|
3
|
-
|
4
|
-
from .controller import SummaryController
|
5
|
-
|
6
|
-
|
7
|
-
def make_summary_blueprint(summary_controller: SummaryController) -> Blueprint:
|
8
|
-
blueprint = Blueprint("summary", __name__, template_folder="templates")
|
9
|
-
|
10
|
-
@blueprint.route("/")
|
11
|
-
def index():
|
12
|
-
return render_template("summary/index.html.j2", **summary_controller.render())
|
13
|
-
|
14
|
-
return blueprint
|
File without changes
|
@@ -1,29 +0,0 @@
|
|
1
|
-
from flask import Blueprint
|
2
|
-
from flask import Response
|
3
|
-
|
4
|
-
from .controller import TileController
|
5
|
-
|
6
|
-
|
7
|
-
def make_tile_blueprint(tile_controller: TileController) -> Blueprint:
|
8
|
-
blueprint = Blueprint("tiles", __name__, template_folder="templates")
|
9
|
-
|
10
|
-
@blueprint.route("/color/<z>/<x>/<y>.png")
|
11
|
-
def tile_color(x: str, y: str, z: str):
|
12
|
-
return Response(
|
13
|
-
tile_controller.render_color(int(x), int(y), int(z)), mimetype="image/png"
|
14
|
-
)
|
15
|
-
|
16
|
-
@blueprint.route("/grayscale/<z>/<x>/<y>.png")
|
17
|
-
def tile_grayscale(x: str, y: str, z: str):
|
18
|
-
return Response(
|
19
|
-
tile_controller.render_grayscale(int(x), int(y), int(z)),
|
20
|
-
mimetype="image/png",
|
21
|
-
)
|
22
|
-
|
23
|
-
@blueprint.route("/pastel/<z>/<x>/<y>.png")
|
24
|
-
def tile_pastel(x: str, y: str, z: str):
|
25
|
-
return Response(
|
26
|
-
tile_controller.render_pastel(int(x), int(y), int(z)), mimetype="image/png"
|
27
|
-
)
|
28
|
-
|
29
|
-
return blueprint
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import io
|
2
|
-
|
3
|
-
import matplotlib.pyplot as pl
|
4
|
-
import numpy as np
|
5
|
-
|
6
|
-
from geo_activity_playground.core.config import Config
|
7
|
-
from geo_activity_playground.core.raster_map import get_tile
|
8
|
-
|
9
|
-
|
10
|
-
class TileController:
|
11
|
-
def __init__(self, config: Config):
|
12
|
-
self._config = config
|
13
|
-
|
14
|
-
def render_color(self, x: int, y: int, z: int) -> bytes:
|
15
|
-
map_tile = np.array(get_tile(z, x, y, self._config.map_tile_url)) / 255
|
16
|
-
f = io.BytesIO()
|
17
|
-
pl.imsave(f, map_tile, format="png")
|
18
|
-
return bytes(f.getbuffer())
|
19
|
-
|
20
|
-
def render_grayscale(self, x: int, y: int, z: int) -> bytes:
|
21
|
-
map_tile = np.array(get_tile(z, x, y, self._config.map_tile_url)) / 255
|
22
|
-
map_tile = np.sum(map_tile * [0.2126, 0.7152, 0.0722], axis=2) # to grayscale
|
23
|
-
map_tile = np.dstack((map_tile, map_tile, map_tile)) # to rgb
|
24
|
-
f = io.BytesIO()
|
25
|
-
pl.imsave(f, map_tile, format="png")
|
26
|
-
return bytes(f.getbuffer())
|
27
|
-
|
28
|
-
def render_pastel(self, x: int, y: int, z: int) -> bytes:
|
29
|
-
map_tile = np.array(get_tile(z, x, y, self._config.map_tile_url)) / 255
|
30
|
-
averaged_tile = np.sum(map_tile * [0.2126, 0.7152, 0.0722], axis=2)
|
31
|
-
grayscale_tile = np.dstack((averaged_tile, averaged_tile, averaged_tile))
|
32
|
-
factor = 0.7
|
33
|
-
pastel_tile = factor * grayscale_tile + (1 - factor) * map_tile
|
34
|
-
f = io.BytesIO()
|
35
|
-
pl.imsave(f, pastel_tile, format="png")
|
36
|
-
return bytes(f.getbuffer())
|
File without changes
|
File without changes
|
File without changes
|
/geo_activity_playground/webui/{square_planner/templates → templates}/square_planner/index.html.j2
RENAMED
File without changes
|
File without changes
|
{geo_activity_playground-0.35.1.dist-info → geo_activity_playground-0.36.1.dist-info}/LICENSE
RENAMED
File without changes
|
File without changes
|
File without changes
|