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

No atlas when no map in QGIS print layout #59

Closed
ghtmtt opened this issue Sep 15, 2022 · 3 comments · Fixed by #62
Closed

No atlas when no map in QGIS print layout #59

ghtmtt opened this issue Sep 15, 2022 · 3 comments · Fixed by #62

Comments

@ghtmtt
Copy link

ghtmtt commented Sep 15, 2022

If in QGIS a print layout is created without a map, e.g. only some tables and text labels for a report-like use, the plugin is not generating anything.

The request points to:

status:fail
message: "Internal 'atlasprint' service error"

while the plugin error on the server is:

09:21:03 CRITICAL AtlasPrint[2754]: Unhandled exception:
Traceback (most recent call last):
  File "/var/www/qgis-server/plugins/atlasprint_old/service.py", line 173, in get_print
    **additional_params
  File "/var/www/qgis-server/plugins/atlasprint_old/core.py", line 143, in print_layout
    if not scales and atlas_layout.referenceMap().atlasScalingMode() == QgsLayoutItemMap.Predefined:
AttributeError: 'NoneType' object has no attribute 'atlasScalingMode'

09:21:03 CRITICAL AtlasPrint[2754]: Atlas print request error 500: Internal 'atlasprint' service error

adding a map, and checking the Exclude item from exports in the Rendering tab works, but it seems like a hack :)

Is this by design?

@Gustry
Copy link
Member

Gustry commented Sep 15, 2022

Is this by design?

No, it's not by design. It's just because most QGIS layouts have a map, we didn't think about this use-case when working on this plugin. A patch would be welcome ;-)

@ghtmtt
Copy link
Author

ghtmtt commented Sep 15, 2022

a functional workaround is something like that:

        try: 
            if not scales and atlas_layout.referenceMap().atlasScalingMode() == QgsLayoutItemMap.Predefined:
                use_project = project.useProjectScales()
                map_scales = project.mapScales()
                if not use_project or len(map_scales) == 0:
                    logger.info(
                        'Map scales not found in project, fetching predefined map scales in global config'
                    )
                    map_scales = global_scales()
                settings.predefinedMapScales = map_scales
        except:
            pass

@ghtmtt
Copy link
Author

ghtmtt commented Oct 21, 2022

that's great. Thanks!

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 a pull request may close this issue.

2 participants