Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the lookup for a layer theme field #2022

Merged
merged 2 commits into from
Mar 21, 2025

Conversation

simon-leech
Copy link
Contributor

A layer with a field defined in the theme that matches to a template in workspace.templates will error.

  "themes": {
      "a": {
        "title": "Theme A",
        "type": "categorized",
        "field": "theme_field"
   }
}

If there's a layer of the name theme_field - the thematic will fail.

Solution

  • Change the lookup from fieldTemplate.template to fieldTemplate.field
 if (Object.hasOwn(req.params.workspace.templates, field)) {
      const fieldTemplate = await getTemplate(field);

    // Previously 
    value = fieldTemplate.template || ''; 
   // New
      value = fieldTemplate.field  || field;
    }

This will mean that the lookup requires a template that contains a field key - which is the SQL for the calculated field for the theme. Also, by setting the || to field, it means that if this is not found - the original field is used.

@simon-leech simon-leech added the Bug A genuine bug. There must be some form of error exception to work with. label Mar 20, 2025
@simon-leech simon-leech linked an issue Mar 20, 2025 that may be closed by this pull request
@simon-leech simon-leech marked this pull request as ready for review March 20, 2025 15:25
Copy link
Member

@dbauszus-glx dbauszus-glx left a comment

Choose a reason for hiding this comment

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

The template must have a field instead of a template string.

{
  "title": "A + B rounded",
  "type": "graduated",
  "field": "a_and_b",
  "template": {
    "key": "a_and_b"
    "field": "round(field_a + field_b)" 
  }
} 

@RobAndrewHurst RobAndrewHurst merged commit ffb7990 into GEOLYTIX:minor Mar 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A genuine bug. There must be some form of error exception to work with.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Layer with field lookup - crashes if matching layer key
3 participants