fix(map): trace stream layer from resolved anchors, not a guessed region - #27
Merged
Conversation
The GET_FLOWLINE_GEOMETRIES step re-derived its own anchor set and applied
whichever region it happened to be handed, which is a guess the other two
layers never make. Both guesses produce a visibly wrong map:
- anchor region (previous behaviour): the downstream prebuilts and the
editor both put the region on the *target* block, so the facility side
came through unfiltered. The trace started from every matching facility
in the country and the stream layer covered the USA — blue flowlines
across the Ohio basin for a Maine question.
- target region (first attempt at a fix): drops anchors sitting outside
the region that genuinely drain into it. For "samples in Maine
downstream of Solid Waste Landfills", 16 of the 39 contributing
landfills are in New Hampshire, so 41% of the traces vanished and Maine
sample points along the Androscoggin were left with no stream beneath
them.
FIND_ANCHOR_IRIS has already resolved the correct anchors by this point —
they passed both the anchor-side and target-side filters — so bind those
IRIs directly and drop the region clause. The layer is now consistent with
the facility layer by construction.
Verified against the live federation endpoint for the question above:
1,446 flowlines, bbox lon -71.30..-67.72 / lat 42.97..46.88, zero vertices
west of -80, Rumford and Jay coverage restored (249 and 203 vertices, both
previously empty), 0.84s. Reusing the resolved IRIs is faster than the
re-derivation it replaces. Empty anchor sets emit `VALUES ?x { }`, which the
endpoint accepts and returns no rows for.
|
This PR was not deployed automatically as @prayaslashkari does not have access to the Railway project. In order to get automatic PR deploys, please add @prayaslashkari to your workspace on Railway. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The stream layer drew the wrong rivers.
For the question "what samples in Maine are downstream of Solid Waste Landfill facilities", the blue stream layer covered most of the eastern United States, including the whole Ohio basin. The samples and facilities layers were correct. Only the streams were wrong.
How
The cause
The step that loads stream shapes built its own list of facilities to trace from, instead of using the list the pipeline had already resolved. It then applied whichever region filter it happened to be handed.
That guess is wrong either way:
The fix
FIND_ANCHOR_IRISruns earlier and has already worked out the correct facilities. They passed the filters on both sides of the question.So this change binds those IRIs directly and drops the region clause. The stream layer now matches the facility layer by construction. There is no guess left to get wrong.
Verified against the live federation endpoint
Using the Maine landfill question:
The speedup is because the database no longer rebuilds the facility set.
Build passes. No new lint errors.
Caveats
VALUESblock. The endpoint accepts this and returns nothing, so the layer is simply empty.