Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@ repos:
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args:
- "--py38-plus"

10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Documentation interne
* Tests unitaires pour la classe RasterSet
* Classe Raster : constructeur à partir des paramètres

* Pyramid
* Fonction de calcul de la taille d'une pyramide
* Générateur de lecture de la liste du contenu
Expand Down Expand Up @@ -75,7 +75,7 @@ Lecture par système de fichier virtuel avec GDAL
* Utils
* Meilleure gestion de reprojection par `reproject_bbox` : on détecte des systèmes identiques en entrée ou quand seul l'ordre des axes changent, pour éviter le calcul
* Ajout de la fonction de reprojection d'un point `reproject_point` : on détecte des systèmes identiques en entrée ou quand seul l'ordre des axes changent, pour éviter le calcul

### [Changed]

* Utils :
Expand All @@ -98,8 +98,8 @@ Ajout de fonctionnalités de lecture de donnée d'une pyramide et suivi des reco
* Storage :
* Fonction de lecture binaire, complète ou partielle, d'un fichier ou objet S3 ou CEPH
* Exceptions : NotImplementedError permet de préciser qu'une fonctionnalité n'a pas été implémentée pour tous les cas. Ici, on ne gère pas la décompression des données raster pour les compressions packbit et LZW
* Ajout de la publication PyPI dans la CI GitHub

* Ajout de la publication PyPI dans la CI GitHub

### [Changed]

Expand Down Expand Up @@ -181,4 +181,4 @@ Initialisation des librairies Python utilisées par les outils python à venir d
* Librairie de gestion d'un descripteur de pyramide
* chargement depuis un descripteur ou par clone (avec changement de stockage)
* écriture du descripteur
* Tests unitaires couvrant ces librairies
* Tests unitaires couvrant ces librairies
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ doc = [

dev = [
"black",
"isort >= 5.12.0",
"pre-commit >3,<4"
]

Expand Down
6 changes: 3 additions & 3 deletions src/rok4/Layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
- `Layer` - Descriptor to broadcast pyramids' data
"""

from typing import Dict, List, Tuple, Union
import json
from json.decoder import JSONDecodeError
import os
import re
from json.decoder import JSONDecodeError
from typing import Dict, List, Tuple, Union

from rok4.Exceptions import *
from rok4.Pyramid import Pyramid, PyramidType
from rok4.TileMatrixSet import TileMatrixSet
from rok4.Storage import *
from rok4.TileMatrixSet import TileMatrixSet
from rok4.Utils import *


Expand Down
31 changes: 14 additions & 17 deletions src/rok4/Pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
- `Level` - Level of a pyramid
"""

from typing import Dict, List, Tuple, Union, Iterator
import io
import json
from json.decoder import JSONDecodeError
import os
import re
import numpy
import zlib
import io
from json.decoder import JSONDecodeError
from typing import Dict, Iterator, List, Tuple, Union

import mapbox_vector_tile
import numpy
from PIL import Image

from rok4.Exceptions import *
from rok4.TileMatrixSet import TileMatrixSet, TileMatrix
from rok4.Storage import *
from rok4.TileMatrixSet import TileMatrix, TileMatrixSet
from rok4.Utils import *


Expand Down Expand Up @@ -549,11 +550,8 @@ def serializable(self) -> Dict:
Returns:
Dict: descriptor structured object description
"""

serialization = {
"tile_matrix_set": self.__tms.name,
"format": self.__format
}

serialization = {"tile_matrix_set": self.__tms.name, "format": self.__format}

serialization["levels"] = []
sorted_levels = sorted(self.__levels.values(), key=lambda l: l.resolution, reverse=True)
Expand Down Expand Up @@ -620,7 +618,7 @@ def storage_root(self) -> str:
Returns:
str: Pyramid's storage root
"""

return self.__storage["root"].split("@", 1)[
0
] # Suppression de l'éventuel hôte de spécification du cluster S3
Expand Down Expand Up @@ -670,7 +668,6 @@ def format(self) -> str:

@property
def tile_extension(self) -> str:

if self.__format in [
"TIFF_RAW_UINT8",
"TIFF_LZW_UINT8",
Expand Down Expand Up @@ -835,7 +832,7 @@ def get_level(self, level_id: str) -> "Level":
Returns:
The corresponding pyramid's level, None if not present
"""

return self.__levels.get(level_id, None)

def get_levels(self, bottom_id: str = None, top_id: str = None) -> List[Level]:
Expand Down Expand Up @@ -1019,7 +1016,6 @@ def get_slab_path_from_infos(
else:
return slab_path


def get_tile_data_binary(self, level: str, column: int, row: int) -> str:
"""Get a pyramid's tile as binary string

Expand Down Expand Up @@ -1182,7 +1178,6 @@ def get_tile_data_raster(self, level: str, column: int, row: int) -> numpy.ndarr
level_object = self.get_level(level)

if self.__format == "TIFF_JPG_UINT8" or self.__format == "TIFF_JPG90_UINT8":

try:
img = Image.open(io.BytesIO(binary_tile))
except Exception as e:
Expand Down Expand Up @@ -1379,6 +1374,8 @@ def size(self) -> int:
Returns:
int: size of the pyramid
"""
if not hasattr(self,"_Pyramid__size") :
self.__size = size_path(get_path_from_infos(self.__storage["type"], self.__storage["root"], self.__name))
if not hasattr(self, "_Pyramid__size"):
self.__size = size_path(
get_path_from_infos(self.__storage["type"], self.__storage["root"], self.__name)
)
return self.__size
4 changes: 2 additions & 2 deletions src/rok4/Raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import json
import re
from enum import Enum
from typing import Tuple, Dict
from typing import Dict, Tuple

from osgeo import ogr, gdal
from osgeo import gdal, ogr

from rok4.Storage import exists, get_osgeo_path, put_data_str
from rok4.Utils import ColorFormat, compute_bbox, compute_format
Expand Down
Loading