Skip to content

fix(origin): correct the map window at +180 and after rotating back - #142

Merged
berkgeveci merged 1 commit into
Kitware:masterfrom
berkgeveci:fix/map-origin-window
Sep 22, 2026
Merged

berkgeveci merged 1 commit into
Kitware:masterfrom
berkgeveci:fix/map-origin-window

Conversation

@berkgeveci

Copy link
Copy Markdown
Collaborator

Two defects in the map-origin feature, both on the dycore (np4) path.

Setting the origin to +180 blanked the map. EAMCenterMeridian's passthrough shortcut tested the origins modulo a turn, so with the dycore reader's [-180, 180) input a +180 origin looked like a window already in place and the filter did nothing. A window a whole turn away covers the same meridians but names them 360 degrees apart, and everything downstream reads coordinates, not residues: EAMProject then subtracted a full turn and clipped, collapsing the mesh onto the left rim. The passthrough now requires the two origins to match exactly, and a whole-turn offset takes a new branch in the rebuild -- the cut would land on the window's own edge and leave one side empty, so the mesh is simply translated rather than clipped. That is also ~14x cheaper per tick than the clip path it replaces.

Rotating away, cropping latitude and rotating back to -180 produced a mesh cropped along the wrong cells. EAMExtract validated its cell-centre cache by comparing modified times, which only order events within one object; upstream legitimately hands back an older object than the cache was built from, because EAMCenterMeridian passes the reader's own points straight through once the map is back in the reader's window. Centres computed from the rotated mesh therefore looked fresh against the unrotated one, and the ghost mask was applied to a mesh it was not computed for. The cell-centre and output caches are now keyed on the identity of the geometry they were built from, plus the crop ranges, with a strong reference held so no other object can land on those addresses -- the same anchoring EAMProject already uses.

Also lets SetMeridian drop the cached output, as SetLongitudeOrigin already does; it sets the same state and had the same staleness hole.

Verified by sweeping 14 origin/crop combinations, including +/-180, +/-179 and seam-crossing crops, on both ne30np4 and ne30pg2, comparing point/cell counts and bounds against a freshly built pipeline at the same settings: all 28 match, and every stage still takes its cache-hit branch on a slicing tick.

Two defects in the map-origin feature, both on the dycore (np4) path.

Setting the origin to +180 blanked the map. EAMCenterMeridian's
passthrough shortcut tested the origins modulo a turn, so with the
dycore reader's [-180, 180) input a +180 origin looked like a window
already in place and the filter did nothing. A window a whole turn away
covers the same meridians but names them 360 degrees apart, and
everything downstream reads coordinates, not residues: EAMProject then
subtracted a full turn and clipped, collapsing the mesh onto the left
rim. The passthrough now requires the two origins to match exactly, and
a whole-turn offset takes a new branch in the rebuild -- the cut would
land on the window's own edge and leave one side empty, so the mesh is
simply translated rather than clipped. That is also ~14x cheaper per
tick than the clip path it replaces.

Rotating away, cropping latitude and rotating back to -180 produced a
mesh cropped along the wrong cells. EAMExtract validated its cell-centre
cache by comparing modified times, which only order events within one
object; upstream legitimately hands back an *older* object than the
cache was built from, because EAMCenterMeridian passes the reader's own
points straight through once the map is back in the reader's window.
Centres computed from the rotated mesh therefore looked fresh against
the unrotated one, and the ghost mask was applied to a mesh it was not
computed for. The cell-centre and output caches are now keyed on the
identity of the geometry they were built from, plus the crop ranges,
with a strong reference held so no other object can land on those
addresses -- the same anchoring EAMProject already uses.

Also lets SetMeridian drop the cached output, as SetLongitudeOrigin
already does; it sets the same state and had the same staleness hole.

Verified by sweeping 14 origin/crop combinations, including +/-180,
+/-179 and seam-crossing crops, on both ne30np4 and ne30pg2, comparing
point/cell counts and bounds against a freshly built pipeline at the
same settings: all 28 match, and every stage still takes its cache-hit
branch on a slicing tick.
@berkgeveci

Copy link
Copy Markdown
Collaborator Author

@jourdain can you review?

@berkgeveci
berkgeveci requested a review from jourdain September 22, 2026 16:06
@berkgeveci
berkgeveci merged commit d8bf451 into Kitware:master Sep 22, 2026
1 check passed
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.

2 participants