Skip to content

Commit 1ce51bd

Browse files
author
frankfeng
committed
Fix indentation bug
1 parent 7a64a76 commit 1ce51bd

File tree

1 file changed

+77
-77
lines changed

1 file changed

+77
-77
lines changed

geotessera/core.py

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -238,89 +238,89 @@ def _ensure_block_loaded(self, year: int, lon: float, lat: float):
238238
# Update available embeddings cache
239239
self._parse_available_embeddings()
240240

241-
def _load_all_blocks(self):
242-
"""Load all available block registries to build complete embedding list.
243-
244-
This method is used when a complete listing of all embeddings is needed,
245-
such as for generating coverage maps. It parses the master registry to
246-
find all block files and loads them.
247-
"""
248-
try:
249-
cache_path = self._cache_dir if self._cache_dir else pooch.os_cache("geotessera")
250-
registry_file = Path(cache_path) / "registry.txt"
251-
252-
if not registry_file.exists():
253-
print("Warning: Master registry not found")
254-
return
241+
def _load_all_blocks(self):
242+
"""Load all available block registries to build complete embedding list.
255243
256-
# Parse registry.txt to find all block registry files
257-
block_files = []
258-
with open(registry_file, 'r') as f:
259-
for line in f:
260-
line = line.strip()
261-
if line and not line.startswith('#'):
262-
parts = line.split(' ', 1)
263-
if len(parts) == 2:
264-
filename = parts[0]
265-
# Look for block registry files (format: registry_YYYY_lonXXX_latYYY.txt)
266-
if filename.startswith('registry_') and '_lon' in filename and '_lat' in filename and filename.endswith('.txt'):
267-
block_files.append(filename)
268-
269-
print(f"Found {len(block_files)} block registry files to load")
270-
271-
# Load each block registry
272-
for i, block_file in enumerate(block_files):
273-
if (i + 1) % 100 == 0: # Progress indicator every 100 blocks
274-
print(f"Loading block registries: {i + 1}/{len(block_files)}")
244+
This method is used when a complete listing of all embeddings is needed,
245+
such as for generating coverage maps. It parses the master registry to
246+
find all block files and loads them.
247+
"""
248+
try:
249+
cache_path = self._cache_dir if self._cache_dir else pooch.os_cache("geotessera")
250+
registry_file = Path(cache_path) / "registry.txt"
275251

276-
try:
277-
# Download the block registry file
278-
registry_url = f"{TESSERA_BASE_URL}/{self.version}/registry/{block_file}"
279-
registry_hash = self._get_registry_hash(block_file)
280-
281-
downloaded_file = pooch.retrieve(
282-
url=registry_url,
283-
known_hash=registry_hash,
284-
fname=block_file,
285-
path=self._registry_base_dir,
286-
progressbar=False # Don't show progress for individual files
287-
)
288-
289-
# Load the registry into the pooch instance
290-
self._pooch.load_registry(downloaded_file)
252+
if not registry_file.exists():
253+
print("Warning: Master registry not found")
254+
return
255+
256+
# Parse registry.txt to find all block registry files
257+
block_files = []
258+
with open(registry_file, 'r') as f:
259+
for line in f:
260+
line = line.strip()
261+
if line and not line.startswith('#'):
262+
parts = line.split(' ', 1)
263+
if len(parts) == 2:
264+
filename = parts[0]
265+
# Look for block registry files (format: registry_YYYY_lonXXX_latYYY.txt)
266+
if filename.startswith('registry_') and '_lon' in filename and '_lat' in filename and filename.endswith('.txt'):
267+
block_files.append(filename)
268+
269+
print(f"Found {len(block_files)} block registry files to load")
270+
271+
# Load each block registry
272+
for i, block_file in enumerate(block_files):
273+
if (i + 1) % 100 == 0: # Progress indicator every 100 blocks
274+
print(f"Loading block registries: {i + 1}/{len(block_files)}")
291275

292-
# Mark this block as loaded
293-
# Parse filename format: registry_YYYY_lonXXX_latYYY.txt
294-
# Examples: registry_2024_lon-15_lat10.txt, registry_2024_lon130_lat45.txt
295-
parts = block_file.replace('.txt', '').split('_')
296-
if len(parts) >= 4:
297-
year = int(parts[1]) # parts[0] is "registry", parts[1] is year
276+
try:
277+
# Download the block registry file
278+
registry_url = f"{TESSERA_BASE_URL}/{self.version}/registry/{block_file}"
279+
registry_hash = self._get_registry_hash(block_file)
298280

299-
# Extract lon and lat values
300-
lon_part = None
301-
lat_part = None
302-
for j, part in enumerate(parts):
303-
if part.startswith('lon'):
304-
lon_part = part[3:] # Remove 'lon' prefix
305-
elif part.startswith('lat'):
306-
lat_part = part[3:] # Remove 'lat' prefix
281+
downloaded_file = pooch.retrieve(
282+
url=registry_url,
283+
known_hash=registry_hash,
284+
fname=block_file,
285+
path=self._registry_base_dir,
286+
progressbar=False # Don't show progress for individual files
287+
)
307288

308-
if lon_part and lat_part:
309-
# Convert to block coordinates (assuming these are already block coordinates)
310-
block_lon = int(lon_part)
311-
block_lat = int(lat_part)
312-
self._loaded_blocks.add((year, block_lon, block_lat))
289+
# Load the registry into the pooch instance
290+
self._pooch.load_registry(downloaded_file)
313291

314-
except Exception as e:
315-
print(f"Warning: Failed to load block registry {block_file}: {e}")
316-
continue
317-
318-
# Update available embeddings cache
319-
self._parse_available_embeddings()
320-
print(f"Loaded {len(self._available_embeddings)} total embeddings")
321-
322-
except Exception as e:
323-
print(f"Error loading all blocks: {e}")
292+
# Mark this block as loaded
293+
# Parse filename format: registry_YYYY_lonXXX_latYYY.txt
294+
# Examples: registry_2024_lon-15_lat10.txt, registry_2024_lon130_lat45.txt
295+
parts = block_file.replace('.txt', '').split('_')
296+
if len(parts) >= 4:
297+
year = int(parts[1]) # parts[0] is "registry", parts[1] is year
298+
299+
# Extract lon and lat values
300+
lon_part = None
301+
lat_part = None
302+
for j, part in enumerate(parts):
303+
if part.startswith('lon'):
304+
lon_part = part[3:] # Remove 'lon' prefix
305+
elif part.startswith('lat'):
306+
lat_part = part[3:] # Remove 'lat' prefix
307+
308+
if lon_part and lat_part:
309+
# Convert to block coordinates (assuming these are already block coordinates)
310+
block_lon = int(lon_part)
311+
block_lat = int(lat_part)
312+
self._loaded_blocks.add((year, block_lon, block_lat))
313+
314+
except Exception as e:
315+
print(f"Warning: Failed to load block registry {block_file}: {e}")
316+
continue
317+
318+
# Update available embeddings cache
319+
self._parse_available_embeddings()
320+
print(f"Loaded {len(self._available_embeddings)} total embeddings")
321+
322+
except Exception as e:
323+
print(f"Error loading all blocks: {e}")
324324

325325
def _ensure_tile_block_loaded(self, lon: float, lat: float):
326326
"""Ensure registry data for a specific tile block is loaded.

0 commit comments

Comments
 (0)