mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-29 19:36:20 -05:00
Map search added to global search. Preview cards are displayed for all results in new Map tab.
Map viewer has simple search. Map search databases can be downloaded from CDN, or built locally. Map searches can be built offline, but will not have enriched things like state names downloaded from Wikidata.
This commit is contained in:
parent
aaa3c0aff7
commit
c726654de9
21 changed files with 1831 additions and 62 deletions
|
|
@ -33,13 +33,16 @@ def get_pmtiles_files() -> List[dict]:
|
|||
path=str(path.relative_to(get_media_directory())),
|
||||
size=stat.st_size,
|
||||
mtime=stat.st_mtime,
|
||||
has_search_index=path.with_suffix('.search.db').is_file(),
|
||||
))
|
||||
|
||||
return files
|
||||
|
||||
|
||||
def delete_pmtiles_file(filename: str) -> bool:
|
||||
"""Delete a PMTiles file from the map directory. Returns True if the file was deleted."""
|
||||
"""Delete a PMTiles file from the map directory. Returns True if the file was deleted.
|
||||
|
||||
Also deletes the companion .search.db file if it exists."""
|
||||
map_directory = get_map_directory()
|
||||
# Prevent path traversal.
|
||||
path = (map_directory / filename).resolve()
|
||||
|
|
@ -49,6 +52,11 @@ def delete_pmtiles_file(filename: str) -> bool:
|
|||
if path.is_file() and path.suffix == '.pmtiles':
|
||||
path.unlink()
|
||||
logger.warning(f'Deleted PMTiles file: {path}')
|
||||
# Also delete companion search index.
|
||||
search_db = path.with_suffix('.search.db')
|
||||
if search_db.is_file():
|
||||
search_db.unlink()
|
||||
logger.warning(f'Deleted search index: {search_db}')
|
||||
return True
|
||||
|
||||
return False
|
||||
|
|
@ -73,7 +81,6 @@ def _get_or_create_map_download(session: Session) -> Download:
|
|||
download = download_manager.get_or_create_download(session, MANIFEST_URL, reset_attempts=True,
|
||||
override_skip=True)
|
||||
download.downloader = 'map_catalog'
|
||||
download.sub_downloader = 'map_extract'
|
||||
download.frequency = DownloadFrequency.days180
|
||||
download.settings = {'regions': []}
|
||||
download.location = '/map/manage'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue