Skip to content

Commit

Permalink
Merge pull request #60 from VIDA-NYU/merge
Browse files Browse the repository at this point in the history
black/zoom.png should be black/tilesize.png
  • Loading branch information
Mary-h86 authored Apr 11, 2024
2 parents f77a674 + ba7ed6a commit fffb6ca
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/tile2net/raster/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from tile2net.raster.input_dir import InputDir
from tile2net.raster.validate import validate
from tile2net.logger import logger
import shutil

PathLike = Union[str, _PathLike]

Expand All @@ -61,7 +62,11 @@ def __set_name__(self, owner, name):

@cached_property
def path(self):
result: Path = self.owner.project.resources.path / 'black' / f'{self.owner.zoom}.png'
result: Path = (
self.owner.project.resources.path /
'black' /
f"{self.owner.base_tilesize}.png"
)
result.parent.mkdir(parents=True, exist_ok=True)
if not result.exists():
imageio.v3.imwrite(result, self.array)
Expand All @@ -72,7 +77,7 @@ def __fspath__(self):

@cached_property
def array(self):
return np.zeros((self.owner.base_tilesize, self.owner.base_tilesize, 3), dtype=np.uint8)
return np.zeros(( self.owner.base_tilesize, self.owner.base_tilesize, 3 ), dtype=np.uint8)


class Raster(Grid):
Expand Down Expand Up @@ -641,8 +646,13 @@ def head(url: str) -> int:
logger.info(f'{loc.sum():,} tiles returned 404 from the server.')
if loc.any():
src = self.black.__fspath__()
for path in paths[loc]:
os.symlink(src, path)
assert os.path.exists(src)
try:
for path in paths[loc]:
os.symlink(src, path)
except PermissionError:
for path in paths[loc]:
shutil.copyfile(src, path)
logger.debug(
f'{loc.sum():,} tiles were not found and returned 404 from the server '
f'so they were set as symlinks to {src}.'
Expand Down

0 comments on commit fffb6ca

Please sign in to comment.