Skip to content

kmltools: accept Topography/DTopography entries and draw the crop used - #764

Open
mandli wants to merge 1 commit into
clawpack:masterfrom
mandli:kml-topo-objects
Open

mandli wants to merge 1 commit into
clawpack:masterfrom
mandli:kml-topo-objects

Conversation

@mandli

@mandli mandli commented Oct 19, 2026

Copy link
Copy Markdown
Member

kmltools.make_input_data_kmls read topofiles and dtopofiles only in the legacy list form, taking the path from f[-1] and the type from f[0]. A setrun.py that appends Topography or DTopography objects, which is the current style, failed with

TypeError: 'Topography' object is not subscriptable

That happened outside the try, so no kml files were written at all. For a cropped topofile, the box also showed the whole file rather than the region GeoClaw uses. That matters for the multi-tile setups in #760, where only part of each tile is used.


Claude Analysis

Changes

  • make_input_data_kmls converts entries with the same TopographyData._normalize_topofiles() / DTopoData._normalize_dtopofiles() that make data uses. Legacy [type, path] lists still work. Their deprecation warning is left to make data instead of being repeated here.
  • The topo box shows the region used, chosen by the new _topo_region_used():
    • the crop_extent, if one is set;
    • for a topo_entries() descriptor entry, its crop_bounds moved by its lon_wrap_offset;
    • otherwise the file's extent moved by x_shift/y_shift (the plain file extent when there is no shift, as before).
  • topo2kml takes an optional extent= to draw a box other than the file's own extent. Existing calls are unchanged.

Tests

tests/test_kmltools_inputs.py runs make_input_data_kmls and reads the box back from the kml it writes:

  • Topography with no crop: the file extent;
  • Topography with crop_extent: the crop;
  • Topography with x_shift/y_shift: the shifted extent;
  • DTopography object: its extent;
  • a legacy [3, path] list: still works, with no second DeprecationWarning.

The four object cases fail on master (0ba4db7b) with the TypeError and pass here. Full tests/: 635 passed, 5 skipped, 1 xfailed.

Related

#760. Once the crop-coverage rule is in, every crop_extent is guaranteed to lie within its file, so the box drawn here is exactly the region used. A tile-selection helper (also #760) would then leave only the tiles that contribute in topofiles, which gives the kml output Randy described.

make_input_data_kmls indexed topofiles/dtopofiles as [type, path] lists and failed with a TypeError on Topography or DTopography objects. It now normalizes entries as TopographyData/DTopoData do, and the topo box shows the region used: crop_extent if set, else the file extent moved by x/y_shift.

Signed-off-by: Kyle Mandli <kyle.mandli@gmail.com>
Assisted-by: claude claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant