Skip to content

Commit 27163a0

Browse files
authored
Merge pull request #62 from OvertureMaps/50-bug-best-practice---links-in-catalogscollections-should-include-a-title-field
[ENHANCEMENT] Add title fields to STAC catalogs/collections
2 parents daba271 + 71f9627 commit 27163a0

6 files changed

Lines changed: 55 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "overture-stac"
3-
version = "1.0.7"
3+
version = "1.0.8"
44
description = "Generate STAC catalogs for Overture Maps Releases"
55
authors = [
66
{name = "Overture Maps Foundation"}

src/overture_stac/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def main():
5555

5656
overture_releases_catalog = pystac.Catalog(
5757
id="Overture Releases",
58+
title="Overture Releases",
5859
description="All Overture Releases",
5960
)
6061

src/overture_stac/overture_stac.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ def process_theme_worker(
6565
logger.info(f"Processing Theme: {theme_name}")
6666

6767
theme_catalog = pystac.Catalog(
68-
id=theme_name, description=f"Overture's {theme_name} theme"
68+
id=theme_name,
69+
title=theme_name,
70+
description=f"Overture's {theme_name} theme",
6971
)
7072

7173
# Add PMTiles link if available for this theme
@@ -211,6 +213,7 @@ def process_theme_worker(
211213
# Create type collection
212214
type_collection = pystac.Collection(
213215
id=type_name,
216+
title=type_name,
214217
description=f"Overture's {type_name} collection",
215218
extent=pystac.Extent(
216219
spatial=pystac.SpatialExtent(
@@ -252,7 +255,7 @@ def process_theme_worker(
252255
if not debug:
253256
type_collection.extra_fields = {"features": total_row_count}
254257

255-
theme_catalog.add_child(type_collection)
258+
theme_catalog.add_child(type_collection, title=type_name)
256259

257260
return (theme_catalog, local_manifest_items, local_type_collections, theme_name)
258261

tests/setup_test_catalog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def build_test_catalog(
112112
# Create root catalog to match CLI structure
113113
root_catalog = pystac.Catalog(
114114
id="Overture Releases",
115+
title="Overture Releases",
115116
description="All Overture Releases (Test)",
116117
)
117118

tests/test_process_theme_worker.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,52 @@ def test_pmtiles_link_added(self, mock_fs, mock_ds):
220220
pmtiles_links = [link for link in theme_catalog.links if link.rel == "pmtiles"]
221221
assert len(pmtiles_links) == 1
222222

223+
@patch("overture_stac.overture_stac.ds")
224+
@patch("overture_stac.overture_stac.fs")
225+
def test_child_links_have_titles(self, mock_fs, mock_ds):
226+
"""Verify all child links on theme_catalog include a title field."""
227+
fragments = [
228+
make_mock_fragment(
229+
"bucket/release/theme=places/type=place/part-00000-abc.parquet",
230+
num_rows=50,
231+
),
232+
]
233+
234+
file_info, dataset = make_mock_theme_type(
235+
"bucket/release/theme=places/type=place", fragments
236+
)
237+
238+
mock_filesystem = MagicMock()
239+
mock_filesystem.get_file_info.return_value = [file_info]
240+
mock_fs.S3FileSystem.return_value = mock_filesystem
241+
mock_ds.dataset.return_value = dataset
242+
243+
theme_catalog, _, _, _ = process_theme_worker(
244+
theme_path="bucket/release/theme=places",
245+
release_path="s3://bucket/release",
246+
s3_region="us-west-2",
247+
debug=False,
248+
release_datetime=datetime(2026, 4, 15),
249+
release="2026-04-15.0",
250+
available_pmtiles={},
251+
)
252+
253+
child_links = [link for link in theme_catalog.links if link.rel == "child"]
254+
assert len(child_links) > 0, "theme_catalog should have child links"
255+
for link in child_links:
256+
assert link.title is not None, (
257+
f"Child link {link.href} is missing a title field"
258+
)
259+
260+
# Also verify the theme_catalog itself has a title
261+
assert theme_catalog.title is not None
262+
assert theme_catalog.title == "places"
263+
264+
# Verify collection has a title
265+
collections = list(theme_catalog.get_children())
266+
assert collections[0].title is not None
267+
assert collections[0].title == "place"
268+
223269

224270
class TestBuildReleaseCatalog:
225271
"""Tests for the build_release_catalog method."""

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)