2022-03-08 13:26:03 -07:00
|
|
|
import json
|
|
|
|
|
from http import HTTPStatus
|
The map draws any PMTiles file as an overlay, in any sub-directory (#962)
Any PMTiles file under the map directory, at any depth, can be shown. The API reads each file's header and metadata and says what it is (basemap, terrain, overlay, unreadable). Overlays are offered in the layer control under the name the file gives itself, hidden until turned on, with a checkbox per vector layer, and are drawn generically.
Map files are named by their path within the map directory everywhere, and unfinished downloads are no longer listed. A file can be ignored from the Manage page; ignored files are kept in a new maps.yaml config.
PMTiles metadata is not decompressed past its size limit, and the standalone viewer encodes map file paths.
2026-11-13 15:11:01 -07:00
|
|
|
from unittest import mock
|
2022-03-08 13:26:03 -07:00
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
import pytest
|
The map draws any PMTiles file as an overlay, in any sub-directory (#962)
Any PMTiles file under the map directory, at any depth, can be shown. The API reads each file's header and metadata and says what it is (basemap, terrain, overlay, unreadable). Overlays are offered in the layer control under the name the file gives itself, hidden until turned on, with a checkbox per vector layer, and are drawn generically.
Map files are named by their path within the map directory everywhere, and unfinished downloads are no longer listed. A file can be ignored from the Manage page; ignored files are kept in a new maps.yaml config.
PMTiles metadata is not decompressed past its size limit, and the standalone viewer encodes map file paths.
2026-11-13 15:11:01 -07:00
|
|
|
import yaml
|
2022-03-08 13:26:03 -07:00
|
|
|
|
The map draws any PMTiles file as an overlay, in any sub-directory (#962)
Any PMTiles file under the map directory, at any depth, can be shown. The API reads each file's header and metadata and says what it is (basemap, terrain, overlay, unreadable). Overlays are offered in the layer control under the name the file gives itself, hidden until turned on, with a checkbox per vector layer, and are drawn generically.
Map files are named by their path within the map directory everywhere, and unfinished downloads are no longer listed. A file can be ignored from the Manage page; ignored files are kept in a new maps.yaml config.
PMTiles metadata is not decompressed past its size limit, and the standalone viewer encodes map file paths.
2026-11-13 15:11:01 -07:00
|
|
|
from modules.map.config import get_maps_config
|
|
|
|
|
from modules.map.conftest import vector_metadata
|
|
|
|
|
from wrolpi.api_utils import api_app
|
|
|
|
|
from wrolpi.common import get_all_configs
|
2026-10-21 16:48:52 -06:00
|
|
|
from wrolpi.conftest import production_like_sessions, write_lock_held_briefly
|
|
|
|
|
|
2022-03-08 13:26:03 -07:00
|
|
|
|
2026-03-29 18:58:31 -06:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_get_files_empty(async_client, test_directory):
|
|
|
|
|
"""An empty map directory returns no files."""
|
2025-10-29 22:16:33 -06:00
|
|
|
request, response = await async_client.get('/api/map/files')
|
2026-03-29 18:58:31 -06:00
|
|
|
assert response.status_code == HTTPStatus.OK
|
|
|
|
|
assert response.json['files'] == []
|
2022-10-27 20:22:11 -06:00
|
|
|
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
@pytest.mark.asyncio
|
2026-03-29 18:58:31 -06:00
|
|
|
async def test_get_files(async_client, test_directory, make_files_structure):
|
|
|
|
|
"""PMTiles files in the map directory are listed."""
|
|
|
|
|
make_files_structure([
|
|
|
|
|
'map/usa.pmtiles',
|
|
|
|
|
'map/oregon.pmtiles',
|
|
|
|
|
'map/not-a-map.txt',
|
2022-10-27 20:22:11 -06:00
|
|
|
])
|
2022-03-08 13:26:03 -07:00
|
|
|
|
2026-03-29 18:58:31 -06:00
|
|
|
request, response = await async_client.get('/api/map/files')
|
|
|
|
|
assert response.status_code == HTTPStatus.OK
|
|
|
|
|
files = response.json['files']
|
|
|
|
|
names = [f['name'] for f in files]
|
|
|
|
|
assert 'oregon.pmtiles' in names
|
|
|
|
|
assert 'usa.pmtiles' in names
|
|
|
|
|
assert 'not-a-map.txt' not in names
|
2022-03-08 13:26:03 -07:00
|
|
|
|
|
|
|
|
|
2026-03-29 18:58:31 -06:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_delete_file(async_client, test_directory, make_files_structure):
|
|
|
|
|
"""A PMTiles file can be deleted."""
|
|
|
|
|
pmtiles_file, = make_files_structure(['map/oregon.pmtiles'])
|
2022-03-08 13:26:03 -07:00
|
|
|
|
2026-03-29 18:58:31 -06:00
|
|
|
# File exists.
|
|
|
|
|
request, response = await async_client.get('/api/map/files')
|
|
|
|
|
assert len(response.json['files']) == 1
|
|
|
|
|
|
|
|
|
|
# Delete the file.
|
|
|
|
|
request, response = await async_client.delete('/api/map/files/oregon.pmtiles')
|
2025-01-26 12:44:16 -07:00
|
|
|
assert response.status_code == HTTPStatus.NO_CONTENT
|
2022-03-08 13:26:03 -07:00
|
|
|
|
2026-03-29 18:58:31 -06:00
|
|
|
# File is gone.
|
|
|
|
|
request, response = await async_client.get('/api/map/files')
|
|
|
|
|
assert len(response.json['files']) == 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_delete_nonexistent_file(async_client, test_directory):
|
|
|
|
|
"""Deleting a nonexistent file returns 404."""
|
|
|
|
|
request, response = await async_client.delete('/api/map/files/nonexistent.pmtiles')
|
|
|
|
|
assert response.status_code == HTTPStatus.NOT_FOUND
|
2022-03-31 07:31:15 -06:00
|
|
|
|
|
|
|
|
|
2026-03-29 18:58:31 -06:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_delete_path_traversal(async_client, test_directory, make_files_structure):
|
|
|
|
|
"""Path traversal attempts are rejected."""
|
|
|
|
|
request, response = await async_client.delete('/api/map/files/..%2F..%2Fetc%2Fpasswd')
|
|
|
|
|
# Path traversal is blocked — either 400 (caught by validation) or 404 (file not found).
|
|
|
|
|
assert response.status_code in (HTTPStatus.BAD_REQUEST, HTTPStatus.NOT_FOUND)
|
2022-10-27 20:22:11 -06:00
|
|
|
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
@pytest.mark.asyncio
|
2026-03-29 18:58:31 -06:00
|
|
|
async def test_get_subscriptions_empty(async_client, test_session, test_directory):
|
|
|
|
|
"""Catalog and empty subscriptions can be fetched."""
|
|
|
|
|
request, response = await async_client.get('/api/map/subscribe')
|
|
|
|
|
assert response.status_code == HTTPStatus.OK
|
|
|
|
|
assert 'catalog' in response.json
|
|
|
|
|
assert 'subscriptions' in response.json
|
|
|
|
|
assert len(response.json['catalog']) > 0
|
|
|
|
|
assert len(response.json['subscriptions']) == 0
|
2022-10-27 20:22:11 -06:00
|
|
|
|
|
|
|
|
|
2026-03-29 18:58:31 -06:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_subscribe_and_unsubscribe(async_client, test_session, test_directory):
|
|
|
|
|
"""A map region can be subscribed to and unsubscribed from."""
|
|
|
|
|
body = json.dumps({'name': 'Alaska', 'region': 'us-alaska'})
|
|
|
|
|
request, response = await async_client.post('/api/map/subscribe', content=body)
|
|
|
|
|
assert response.status_code == HTTPStatus.CREATED
|
|
|
|
|
|
|
|
|
|
# Subscription appears in the list.
|
|
|
|
|
request, response = await async_client.get('/api/map/subscribe')
|
|
|
|
|
assert response.status_code == HTTPStatus.OK
|
|
|
|
|
regions = [s['region'] for s in response.json['subscriptions']]
|
|
|
|
|
assert 'us-alaska' in regions
|
|
|
|
|
|
|
|
|
|
# Unsubscribe.
|
|
|
|
|
request, response = await async_client.delete('/api/map/subscribe/us-alaska')
|
2025-01-26 12:44:16 -07:00
|
|
|
assert response.status_code == HTTPStatus.NO_CONTENT
|
2022-10-27 20:22:11 -06:00
|
|
|
|
2026-03-29 18:58:31 -06:00
|
|
|
# Subscription is gone.
|
|
|
|
|
request, response = await async_client.get('/api/map/subscribe')
|
|
|
|
|
assert len(response.json['subscriptions']) == 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_subscribe_multiple_regions(async_client, test_session, test_directory):
|
|
|
|
|
"""Multiple regions share a single Download record."""
|
|
|
|
|
body = json.dumps({'name': 'Alaska', 'region': 'us-alaska'})
|
|
|
|
|
request, response = await async_client.post('/api/map/subscribe', content=body)
|
|
|
|
|
assert response.status_code == HTTPStatus.CREATED
|
|
|
|
|
|
|
|
|
|
body = json.dumps({'name': 'United States (West)', 'region': 'us-west'})
|
|
|
|
|
request, response = await async_client.post('/api/map/subscribe', content=body)
|
|
|
|
|
assert response.status_code == HTTPStatus.CREATED
|
|
|
|
|
|
|
|
|
|
request, response = await async_client.get('/api/map/subscribe')
|
|
|
|
|
regions = [s['region'] for s in response.json['subscriptions']]
|
|
|
|
|
assert 'us-alaska' in regions
|
|
|
|
|
assert 'us-west' in regions
|
|
|
|
|
|
|
|
|
|
# Unsubscribe one — the other remains.
|
|
|
|
|
request, response = await async_client.delete('/api/map/subscribe/us-alaska')
|
2025-01-26 12:44:16 -07:00
|
|
|
assert response.status_code == HTTPStatus.NO_CONTENT
|
2022-10-27 20:22:11 -06:00
|
|
|
|
2026-03-29 18:58:31 -06:00
|
|
|
request, response = await async_client.get('/api/map/subscribe')
|
|
|
|
|
regions = [s['region'] for s in response.json['subscriptions']]
|
|
|
|
|
assert 'us-alaska' not in regions
|
|
|
|
|
assert 'us-west' in regions
|
2022-03-08 13:26:03 -07:00
|
|
|
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
@pytest.mark.asyncio
|
2026-03-29 18:58:31 -06:00
|
|
|
async def test_subscribe_invalid_region(async_client, test_session, test_directory):
|
|
|
|
|
"""Subscribing to an invalid region returns an error."""
|
|
|
|
|
body = json.dumps({'name': 'Atlantis', 'region': 'atlantis'})
|
|
|
|
|
request, response = await async_client.post('/api/map/subscribe', content=body)
|
2022-10-27 20:22:11 -06:00
|
|
|
assert response.status_code == HTTPStatus.BAD_REQUEST
|
2026-04-04 14:56:25 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_map_default_location_empty(async_client, test_directory):
|
|
|
|
|
"""Default location is null when not set."""
|
|
|
|
|
request, response = await async_client.get('/api/settings')
|
|
|
|
|
assert response.status_code == HTTPStatus.OK
|
|
|
|
|
assert response.json['map_default_location'] is None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_set_and_get_map_default_location(async_client, test_directory):
|
|
|
|
|
"""Setting a default map location persists and is returned in settings."""
|
|
|
|
|
body = json.dumps({'config': {'map_default_location': {'lat': 40.7, 'lon': -111.9, 'zoom': 10.5}}})
|
|
|
|
|
request, response = await async_client.post('/api/config?file_name=wrolpi.yaml', content=body)
|
|
|
|
|
assert response.status_code == HTTPStatus.NO_CONTENT
|
|
|
|
|
|
|
|
|
|
request, response = await async_client.get('/api/settings')
|
|
|
|
|
assert response.status_code == HTTPStatus.OK
|
|
|
|
|
loc = response.json['map_default_location']
|
|
|
|
|
assert loc['lat'] == 40.7
|
|
|
|
|
assert loc['lon'] == -111.9
|
|
|
|
|
assert loc['zoom'] == 10.5
|
2026-10-21 16:48:52 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
@pytest.mark.parametrize('step', ['subscribe', 'unsubscribe'])
|
|
|
|
|
async def test_subscription_writes_wait_for_a_concurrent_writer(async_client, test_session, test_directory, step):
|
|
|
|
|
"""Subscribing and unsubscribing read before they write, so each must begin as a writer: SQLite fails a
|
|
|
|
|
deferred transaction's lock upgrade instantly ("database is locked") if another connection wrote meanwhile."""
|
|
|
|
|
if step == 'unsubscribe':
|
|
|
|
|
_, response = await async_client.post('/api/map/subscribe',
|
|
|
|
|
content=json.dumps({'name': 'Alaska', 'region': 'us-alaska'}))
|
|
|
|
|
assert response.status_code == HTTPStatus.CREATED
|
|
|
|
|
test_session.commit()
|
|
|
|
|
db_file = test_session.get_bind().url.database
|
|
|
|
|
|
|
|
|
|
with production_like_sessions(test_session):
|
|
|
|
|
# Held past any slow work a request does before it writes.
|
|
|
|
|
with write_lock_held_briefly(db_file, seconds=3):
|
|
|
|
|
if step == 'subscribe':
|
|
|
|
|
_, response = await async_client.post('/api/map/subscribe',
|
|
|
|
|
content=json.dumps({'name': 'Alaska', 'region': 'us-alaska'}))
|
|
|
|
|
else:
|
|
|
|
|
_, response = await async_client.delete('/api/map/subscribe/us-alaska')
|
|
|
|
|
assert response.status_code in (HTTPStatus.CREATED, HTTPStatus.NO_CONTENT), response.body
|
|
|
|
|
|
|
|
|
|
_, response = await async_client.get('/api/map/subscribe')
|
|
|
|
|
regions = [i['region'] for i in response.json['subscriptions']]
|
|
|
|
|
assert regions == (['us-alaska'] if step == 'subscribe' else [])
|
The map draws any PMTiles file as an overlay, in any sub-directory (#962)
Any PMTiles file under the map directory, at any depth, can be shown. The API reads each file's header and metadata and says what it is (basemap, terrain, overlay, unreadable). Overlays are offered in the layer control under the name the file gives itself, hidden until turned on, with a checkbox per vector layer, and are drawn generically.
Map files are named by their path within the map directory everywhere, and unfinished downloads are no longer listed. A file can be ignored from the Manage page; ignored files are kept in a new maps.yaml config.
PMTiles metadata is not decompressed past its size limit, and the standalone viewer encodes map file paths.
2026-11-13 15:11:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_get_files_describes_files(async_client, test_directory, make_pmtiles):
|
|
|
|
|
"""A file is described by its own metadata, and by how the map draws it."""
|
|
|
|
|
make_pmtiles('map/usa.pmtiles')
|
|
|
|
|
make_pmtiles('map/extras/features.pmtiles',
|
|
|
|
|
vector_metadata('towers', geometries=dict(towers='Point'), name='Features', description='Things'))
|
|
|
|
|
|
|
|
|
|
request, response = await async_client.get('/api/map/files')
|
|
|
|
|
assert response.status_code == HTTPStatus.OK
|
|
|
|
|
files = {i['map_path']: i for i in response.json['files']}
|
|
|
|
|
assert files['usa.pmtiles']['kind'] == 'basemap'
|
|
|
|
|
assert files['usa.pmtiles']['title'] == 'Protomaps Basemap'
|
|
|
|
|
features = files['extras/features.pmtiles']
|
|
|
|
|
assert features['kind'] == 'overlay'
|
|
|
|
|
assert features['title'] == 'Features'
|
|
|
|
|
assert features['description'] == 'Things'
|
|
|
|
|
assert features['path'] == 'map/extras/features.pmtiles'
|
|
|
|
|
assert features['visible'] is True
|
|
|
|
|
assert features['vector_layers'] == [
|
|
|
|
|
dict(id='towers', minzoom=0, maxzoom=8, description=None, geometry='Point')]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_delete_file_sub_directory(async_client, test_directory, make_pmtiles):
|
|
|
|
|
"""A file in a sub-directory can be deleted."""
|
|
|
|
|
pmtiles_file = make_pmtiles('map/extras/deeper/features.pmtiles')
|
|
|
|
|
|
|
|
|
|
request, response = await async_client.delete('/api/map/files/extras/deeper/features.pmtiles')
|
|
|
|
|
assert response.status_code == HTTPStatus.NO_CONTENT
|
|
|
|
|
assert not pmtiles_file.exists()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_rebuild_search_index_sub_directory(async_client, test_directory, make_pmtiles):
|
|
|
|
|
"""The search index of a file in a sub-directory can be built."""
|
|
|
|
|
pmtiles_file = make_pmtiles('map/regions/oregon.pmtiles')
|
|
|
|
|
|
|
|
|
|
with mock.patch('modules.map.search._check_tippecanoe', return_value=True), \
|
|
|
|
|
mock.patch('modules.map.search._run_build', new_callable=mock.AsyncMock) as mock_run_build:
|
|
|
|
|
request, response = await async_client.post('/api/map/search/rebuild/regions/oregon.pmtiles')
|
|
|
|
|
assert response.status_code == HTTPStatus.ACCEPTED
|
|
|
|
|
cmd, description = mock_run_build.call_args.args
|
|
|
|
|
assert str(pmtiles_file) in cmd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_file_visible(async_client, test_directory, make_pmtiles):
|
|
|
|
|
"""A map file can be ignored and shown again; the choice is saved to the maps config."""
|
|
|
|
|
make_pmtiles('map/extras/api-ignored.pmtiles')
|
|
|
|
|
config_file = test_directory / 'config/maps.yaml'
|
|
|
|
|
|
|
|
|
|
body = dict(map_path='extras/api-ignored.pmtiles', visible=False)
|
|
|
|
|
request, response = await async_client.post('/api/map/files/visible', json=body)
|
|
|
|
|
assert response.status_code == HTTPStatus.NO_CONTENT
|
|
|
|
|
request, response = await async_client.get('/api/map/files')
|
|
|
|
|
assert [i['visible'] for i in response.json['files']] == [False]
|
|
|
|
|
assert yaml.safe_load(config_file.read_text())['ignored_files'] == ['extras/api-ignored.pmtiles']
|
|
|
|
|
|
|
|
|
|
body = dict(map_path='extras/api-ignored.pmtiles', visible=True)
|
|
|
|
|
request, response = await async_client.post('/api/map/files/visible', json=body)
|
|
|
|
|
assert response.status_code == HTTPStatus.NO_CONTENT
|
|
|
|
|
request, response = await async_client.get('/api/map/files')
|
|
|
|
|
assert [i['visible'] for i in response.json['files']] == [True]
|
|
|
|
|
assert yaml.safe_load(config_file.read_text())['ignored_files'] == []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_file_visible_unknown_file(async_client, test_directory):
|
|
|
|
|
"""A file which does not exist cannot be ignored."""
|
|
|
|
|
body = dict(map_path='missing.pmtiles', visible=False)
|
|
|
|
|
request, response = await async_client.post('/api/map/files/visible', json=body)
|
|
|
|
|
assert response.status_code == HTTPStatus.NOT_FOUND
|
|
|
|
|
|
|
|
|
|
body = dict(map_path='../../etc/passwd', visible=False)
|
|
|
|
|
request, response = await async_client.post('/api/map/files/visible', json=body)
|
|
|
|
|
assert response.status_code == HTTPStatus.BAD_REQUEST
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_maps_config_import(async_client, test_directory, make_pmtiles):
|
|
|
|
|
"""A maps config a person edited is applied when it is imported."""
|
|
|
|
|
make_pmtiles('map/hand-edited.pmtiles')
|
|
|
|
|
make_pmtiles('map/other.pmtiles')
|
|
|
|
|
config = get_maps_config()
|
|
|
|
|
config.get_file().parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
config.get_file().write_text(yaml.safe_dump(dict(version=1, ignored_files=['hand-edited.pmtiles'])))
|
|
|
|
|
|
|
|
|
|
config.import_config()
|
|
|
|
|
|
|
|
|
|
request, response = await async_client.get('/api/map/files')
|
|
|
|
|
visible = {i['map_path']: i['visible'] for i in response.json['files']}
|
|
|
|
|
assert visible == {'hand-edited.pmtiles': False, 'other.pmtiles': True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_maps_config_is_shared(async_client):
|
|
|
|
|
"""The maps config lives in the context the Sanic workers share (a config which does not is saved by one
|
|
|
|
|
worker and overwritten by another), and is among the configs WROLPi manages."""
|
|
|
|
|
assert get_maps_config()._config is api_app.shared_ctx.maps_config
|
|
|
|
|
assert get_all_configs()['maps.yaml'] is get_maps_config()
|
2026-11-13 15:41:43 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
The map draws its own icons on an overlay (#967)
An overlay drawn with a style of its own names icons, which needed the sprite sheet that style was made for. The map now ships icons for overlays, the Maki and Temaki sets (both CC0), and always draws those, in both viewers.
The sprite sheet is the translation: its index lists every icon under its own name, under each other name it answers to (modules/map/icons/aliases.json), and in both spellings of each. A name with no icon is drawn as a plain dot. The icons are signed distance fields, so a style's icon color and halo apply.
A pattern is not an icon: what it filled (a fill, a line or an extrusion) is drawn in a translucent color, where removing a pattern used to leave MapLibre's opaque black.
A sprite sheet beside a map file is no longer used, served or reported. wrolpi/scripts/build_map_icons.py builds the sheet from the SVGs; the sheet is committed.
2026-11-13 17:59:03 -07:00
|
|
|
async def test_map_file_has_no_sprite_of_its_own(async_client, test_directory, make_pmtiles):
|
|
|
|
|
"""The map draws its own icons on an overlay: a sprite sheet beside a map file is not served or reported."""
|
2026-11-13 15:41:43 -07:00
|
|
|
make_pmtiles('map/extras/features.pmtiles', vector_metadata('towers'))
|
The map draws its own icons on an overlay (#967)
An overlay drawn with a style of its own names icons, which needed the sprite sheet that style was made for. The map now ships icons for overlays, the Maki and Temaki sets (both CC0), and always draws those, in both viewers.
The sprite sheet is the translation: its index lists every icon under its own name, under each other name it answers to (modules/map/icons/aliases.json), and in both spellings of each. A name with no icon is drawn as a plain dot. The icons are signed distance fields, so a style's icon color and halo apply.
A pattern is not an icon: what it filled (a fill, a line or an extrusion) is drawn in a translucent color, where removing a pattern used to leave MapLibre's opaque black.
A sprite sheet beside a map file is no longer used, served or reported. wrolpi/scripts/build_map_icons.py builds the sheet from the SVGs; the sheet is committed.
2026-11-13 17:59:03 -07:00
|
|
|
(test_directory / 'map/extras/sprite.json').write_text('{}')
|
|
|
|
|
(test_directory / 'map/extras/sprite.png').write_bytes(b'png')
|
2026-11-13 15:41:43 -07:00
|
|
|
|
The map draws its own icons on an overlay (#967)
An overlay drawn with a style of its own names icons, which needed the sprite sheet that style was made for. The map now ships icons for overlays, the Maki and Temaki sets (both CC0), and always draws those, in both viewers.
The sprite sheet is the translation: its index lists every icon under its own name, under each other name it answers to (modules/map/icons/aliases.json), and in both spellings of each. A name with no icon is drawn as a plain dot. The icons are signed distance fields, so a style's icon color and halo apply.
A pattern is not an icon: what it filled (a fill, a line or an extrusion) is drawn in a translucent color, where removing a pattern used to leave MapLibre's opaque black.
A sprite sheet beside a map file is no longer used, served or reported. wrolpi/scripts/build_map_icons.py builds the sheet from the SVGs; the sheet is committed.
2026-11-13 17:59:03 -07:00
|
|
|
request, response = await async_client.get('/api/map/files')
|
|
|
|
|
assert 'has_sprite' not in response.json['files'][0]
|
2026-11-13 15:41:43 -07:00
|
|
|
request, response = await async_client.get('/api/map/files/sprite/extras/features.pmtiles.json')
|
The map draws its own icons on an overlay (#967)
An overlay drawn with a style of its own names icons, which needed the sprite sheet that style was made for. The map now ships icons for overlays, the Maki and Temaki sets (both CC0), and always draws those, in both viewers.
The sprite sheet is the translation: its index lists every icon under its own name, under each other name it answers to (modules/map/icons/aliases.json), and in both spellings of each. A name with no icon is drawn as a plain dot. The icons are signed distance fields, so a style's icon color and halo apply.
A pattern is not an icon: what it filled (a fill, a line or an extrusion) is drawn in a translucent color, where removing a pattern used to leave MapLibre's opaque black.
A sprite sheet beside a map file is no longer used, served or reported. wrolpi/scripts/build_map_icons.py builds the sheet from the SVGs; the sheet is committed.
2026-11-13 17:59:03 -07:00
|
|
|
assert response.status_code in (HTTPStatus.NOT_FOUND, HTTPStatus.METHOD_NOT_ALLOWED)
|