Skip to content

StandardApp: only check c URL parameter against theme extent if constrainExtent is enabled - #801

Merged
manisandro merged 1 commit into
qgis:masterfrom
dominik-warch:feat/url-position-bounds-check
Oct 29, 2026
Merged

manisandro merged 1 commit into
qgis:masterfrom
dominik-warch:feat/url-position-bounds-check

Conversation

@dominik-warch

Copy link
Copy Markdown
Contributor

Addresses #774, implementing option 2: The c URL parameter is only checked against the theme extent if mapOptions.constrainExtent is enabled.

Because this check was also the only guard against invalid values, c is now ignored if it does not contain two valid numbers (for example c=412345, from a truncated link), and the theme opens at its initial extent instead of at 0.

@dominik-warch
dominik-warch deleted the feat/url-position-bounds-check branch October 29, 2026 07:01
@dominik-warch
dominik-warch restored the feat/url-position-bounds-check branch October 29, 2026 08:19
@dominik-warch dominik-warch reopened this Oct 29, 2026
// Only accept c if it is within the theme bounds
if (bounds[0] <= p[0] && p[0] <= bounds[2] && bounds[1] <= p[1] && p[1] <= bounds[3]) {
// If the map is constrained to the theme bounds, only accept c if it is within them
const constrained = ConfigUtils.getPluginConfig("Map").cfg?.mapOptions?.constrainExtent === true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you'll also want to check for mapOptions?.constrainOnlyCenter here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed! constrainOnlyCenter does nothing without constrainExtent since OlMap only passes the extent to the view if constrainExtent is set. With constrainExtent the center has to be inside the theme extent in both cases and without constrainOnlyCenter OL already shifts the view inwards on its own. I tested all combinations to be sure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right!

@manisandro
manisandro merged commit ed13c87 into qgis:master Oct 29, 2026
3 checks passed
@manisandro

Copy link
Copy Markdown
Member

Thanks!

@dominik-warch
dominik-warch deleted the feat/url-position-bounds-check branch October 29, 2026 18:20
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