Skip to content

Commit 44ebeab

Browse files
authored
Merge pull request #23 from rok4/develop
Release 1.5.2
2 parents 16f348f + 195a005 commit 44ebeab

File tree

6 files changed

+105
-25
lines changed

6 files changed

+105
-25
lines changed

.github/labeler.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
ci-cd:
2-
- .github/**/*
2+
- changed-files:
3+
- any-glob-to-any-file:
4+
- .github/**
35

46
dependencies:
5-
- requirements.txt
6-
- requirements/*.txt
7+
- changed-files:
8+
- any-glob-to-any-file:
9+
- requirements.txt
10+
- requirements/*.txt
711

812
documentation:
9-
- docs/**/*
13+
- changed-files:
14+
- any-glob-to-any-file:
15+
- docs/**
1016

1117
enhancement:
12-
- src/**/*
18+
- changed-files:
19+
- any-glob-to-any-file:
20+
- src/**
1321

1422
quality:
15-
- tests/**/*
23+
- changed-files:
24+
- any-glob-to-any-file:
25+
- tests/**
1626

1727
tooling:
18-
- .gitignore
19-
- .pre-commit-config.yaml
20-
- setup.cfg
21-
- pyproject.toml
28+
- changed-files:
29+
- any-glob-to-any-file:
30+
- .gitignore
31+
- .pre-commit-config.yaml
32+
- setup.cfg
33+
- pyproject.toml

.github/workflows/pr-auto-labeler.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ name: "🏷 PR Labeler"
22
on:
33
- pull_request
44

5-
permissions:
6-
contents: read
7-
pull-requests: write
8-
95
jobs:
10-
triage:
6+
labeler:
7+
permissions:
8+
contents: read
9+
pull-requests: write
1110
runs-on: ubuntu-latest
1211
steps:
13-
- uses: actions/labeler@v5
14-
with:
15-
repo-token: "${{ secrets.GITHUB_TOKEN }}"
12+
- uses: actions/labeler@v5

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.5.2
2+
3+
### [Added]
4+
5+
* Outil TMSIZER : possibilité de préciser une aire prédéinie à la place de la bbox et un niveau à la place des dimensions pour l'écriture d'une heatmap (une tuile du niveau correspondra à un pixel)
6+
17
## 1.5.1
28

39
### [Added]

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,22 @@ Conversions possibles (paramètres obligatoires en gras, paramètres facultatifs
165165
| Format en entrée | Options d'entrée | Format en sortie | Options de sortie | Description |
166166
|------------------|------------------|------------------|---------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|
167167
| GETTILE_PARAMS | *`levels=<id>[,<id> ...]`*,*`layers=<id>[,<id> ...]`* | COUNT | | Compte le nombre de GetTile dans les URLs en entrée utilisant le TMS pivot et les éventuels niveaux et couches fournies |
168-
| GETTILE_PARAMS | *`levels=<id>[,<id> ...]`*,*`layers=<id>[,<id> ...]`* | HEATMAP | **`bbox=<xmin>,<ymin>,<xmax>,<ymax>`**, **`dimensions=<width>x<height>`** | Génère une carte de chaleur des tuiles interrogées sur la zone demandée et sur les éventuels niveau et couche fournis |
168+
| GETTILE_PARAMS | *`levels=<id>[,<id> ...]`*,*`layers=<id>[,<id> ...]`* | HEATMAP | **`bbox=<xmin>,<ymin>,<xmax>,<ymax> or area=<id>`**, **`dimensions=<width>x<height> or level=<id>`** | Génère une carte de chaleur des tuiles interrogées sur la zone demandée et sur les éventuels niveaux et couches fournies. Si un niveau est fourni en sortie, on calera la bbox et les résolutions pour avoir un pixel correpondant à l'étendue d'une tuile du niveau. Certaines aires sont prédéfinies pour certaines projections du TMS |
169169
| GEOMETRY | **`format=<WKT\|GeoJSON\|WKB>`**,**`level=<id>`** | GETTILE_PARAMS | | Génére les paramètres de requête GetTile des tuiles du niveau fourni intersectant les géométries en entrée |
170170

171+
Aires prédéfinies pour une carte de chaleur :
172+
173+
* `EPSG:3857`
174+
* `FXX` (France métropolitaine)
175+
171176
Exemple (GETTILE_PARAMS -> HEATMAP) :
172177

173178
`tmsizer -i logs.txt --tms PM -io levels=15,14 -io layer=LAYER.NAME1,LAYER.NAME2,LAYER.NAME3 -if GETTILE_PARAMS -of HEATMAP -oo bbox=65000,6100000,665000,6500000 -oo dimensions=600x400 -o heatmap.tif`
174179

180+
Exemple (GETTILE_PARAMS -> HEATMAP) avec une aire prédéfinie et une correspondance pixel-niveau:
181+
182+
`tmsizer -i logs.txt --tms PM -if GETTILE_PARAMS -of HEATMAP -oo area=FXX -oo level=15 -o heatmap.tif`
183+
175184
## Compiler la suite d'outils
176185

177186
```sh

README.pypi.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,18 @@ Availables conversions (mandatory options in bold, optionnal options in italic)
164164
| Input format | Input options | Output format | Output options | Description |
165165
|----------------|---------------------------------------------------|----------------|---------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
166166
| GETTILE_PARAMS | *`levels=<id>[,<id> ...]`*,*`layers=<id>[,<id> ...]`* | COUNT | | Count the GetTiles requests using the pivot TMS and optionnally the provided level and layer |
167-
| GETTILE_PARAMS | *`levels=<id>[,<id> ...]`*,*`layers=<id>[,<id> ...]`* | HEATMAP | **`bbox=<xmin>,<ymin>,<xmax>,<ymax>`**, **`dimensions=<width>x<height>`** | Create an heat map of requested tiles on the provided area, optionnaly filtering with provided level and layer |
167+
| GETTILE_PARAMS | *`levels=<id>[,<id> ...]`*,*`layers=<id>[,<id> ...]`* | HEATMAP | **`bbox=<xmin>,<ymin>,<xmax>,<ymax> or area=<id>`**, **`dimensions=<width>x<height> or level=<id>`** | Create an heat map of requested tiles on the provided area, optionnaly filtering with provided level and layer |
168168
| GEOMETRY | **`format=<WKT\|GeoJSON\|WKB>`**,**`level=<id>`** | GETTILE_PARAMS | | Generate GetTile query parameters for tiles intersecting input geometries for the provided level |
169169

170+
Available areas for a heatmap :
171+
172+
* `EPSG:3857`
173+
* `FXX` (European France)
174+
170175
Example (GETTILE_PARAMS -> HEATMAP) :
171176

177+
`tmsizer -i logs.txt --tms PM -io levels=15,14 -io layer=LAYER.NAME1,LAYER.NAME2,LAYER.NAME3 -if GETTILE_PARAMS -of HEATMAP -oo bbox=65000,6100000,665000,6500000 -oo dimensions=600x400 -o heatmap.tif`
178+
179+
Example (GETTILE_PARAMS -> HEATMAP) with predefined area and pixel-level superposition:
172180

173-
`tmsizer -i logs.txt --tms PM -io levels=15,14 -io layer=LAYER.NAME1,LAYER.NAME2,LAYER.NAME3 -if GETTILE_PARAMS -of HEATMAP -oo bbox=65000,6100000,665000,6500000 -oo dimensions=600x400 -o heatmap.tif`
181+
`tmsizer -i logs.txt --tms PM -if GETTILE_PARAMS -of HEATMAP -oo area=FXX -oo level=15 -o heatmap.tif`

src/rok4_tools/tmsizer_utils/processors/reduce.py

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ class HeatmapProcessor(Processor):
8585

8686
input_formats_allowed = ["POINT"]
8787

88+
areas = {
89+
"EPSG:3857": {
90+
"FXX": [-649498, 5048729, 1173394, 6661417]
91+
}
92+
}
93+
8894
def __init__(self, input: Processor, **options):
8995
"""Constructor method
9096
@@ -107,7 +113,7 @@ def __init__(self, input: Processor, **options):
107113

108114
self.__input = input
109115

110-
try:
116+
if "bbox" in options:
111117
try:
112118
self.__bbox = [float(c) for c in options["bbox"].split(",")]
113119
self.__bbox = tuple(self.__bbox)
@@ -117,6 +123,18 @@ def __init__(self, input: Processor, **options):
117123
if len(self.__bbox) != 4 or self.__bbox[0] >= self.__bbox[2] or self.__bbox[1] >= self.__bbox[3]:
118124
raise ValueError(f"Option 'bbox' have to be provided with format <xmin>,<ymin>,<xmax>,<ymax> (floats, min < max)")
119125

126+
elif "area" in options:
127+
try:
128+
self.__bbox = self.areas[self.tms.srs][options["area"]]
129+
except KeyError as e:
130+
if self.tms.srs in self.areas:
131+
raise ValueError(f"Area '{options['area']}' is not available for the TMS coordinates system ({self.tms.srs}): available areas are {', '.join(self.areas[self.tms.srs].keys())}")
132+
else :
133+
raise ValueError(f"No defined areas for the TMS coordinates system ({self.tms.srs})")
134+
else:
135+
raise KeyError(f"Option 'bbox' or 'area' is required for a heatmap processing")
136+
137+
if "dimensions" in options:
120138
try:
121139
self.__dimensions = [int(d) for d in options["dimensions"].split("x")]
122140
self.__dimensions = tuple(self.__dimensions)
@@ -130,9 +148,39 @@ def __init__(self, input: Processor, **options):
130148
(self.__bbox[2] - self.__bbox[0]) / self.__dimensions[0],
131149
(self.__bbox[3] - self.__bbox[1]) / self.__dimensions[1]
132150
)
151+
elif "level" in options:
152+
level = self.tms.get_level(options["level"])
153+
if level is None:
154+
raise ValueError(f"The provided level '{options['dimensions']}' (to have one pixel per tile) is not in the TMS")
155+
156+
# On va caler la bbox pour qu'elle coïncide avec les limites de tuiles du niveau demandé
157+
(col_min, row_min, col_max, row_max) = level.bbox_to_tiles(self.__bbox)
158+
159+
# Calage du coin en bas à gauche
160+
(xmin, ymin, xmax, ymax) = level.tile_to_bbox(col_min, row_max)
161+
self.__bbox[0] = xmin
162+
self.__bbox[1] = ymin
163+
164+
# Calage du coin en haut à droite
165+
(xmin, ymin, xmax, ymax) = level.tile_to_bbox(col_max, row_min)
166+
self.__bbox[2] = xmax
167+
self.__bbox[3] = ymax
168+
169+
self.__resolutions = (
170+
xmax - xmin,
171+
ymax - ymin
172+
)
173+
174+
self.__dimensions = (
175+
int((self.__bbox[2] - self.__bbox[0]) / self.__resolutions[0]),
176+
int((self.__bbox[3] - self.__bbox[1]) / self.__resolutions[1])
177+
)
178+
179+
else:
180+
raise KeyError(f"Option 'dimensions' or 'level' is required for a heatmap processing")
133181

134-
except KeyError as e:
135-
raise KeyError(f"Option {e} is required for a heatmap processing")
182+
if self.__dimensions[0] > 10000 or self.__dimensions[1] > 10000:
183+
raise ValueError(f"Heatmap dimensions have to be less than 10 000 x 10 000: here it's {self.__dimensions}")
136184

137185
def process(self) -> Iterator[MemoryFile]:
138186
"""Read point coordinates from the input processor and accumule them as a heat map
@@ -194,4 +242,4 @@ def process(self) -> Iterator[MemoryFile]:
194242
yield memfile
195243

196244
def __str__(self) -> str:
197-
return f"HeatmapProcessor : {self._processed} hits on image with dimensions {self.__dimensions} and bbox {self.__bbox}"
245+
return f"HeatmapProcessor : {self._processed} hits on image with dimensions {self.__dimensions} and bbox {self.__bbox} (resolutions {self.__resolutions})"

0 commit comments

Comments
 (0)