<div dir="ltr"><div>Hello matt,</div><div><br></div>That must have to do with the fact that now it's possible to control more that one map extent with atlas, that means that for each map item you need to check the control by atlas option.<div>
<br></div><div>The same probably applies to the python scripts.</div><div><br></div><div>Hope I helped,</div><div><br></div><div>Alexandre Neto</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 27, 2014 at 11:19 AM, mattwalsh <span dir="ltr"><<a href="mailto:matthew@miningsearchesuk.com" target="_blank">matthew@miningsearchesuk.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I am having a bit trouble migrating a script to QGIS 2.2.<br>
<br>
In QGIS 2.0 I have the following Python script which will load a composer<br>
from template, generate an atlas and export to image.<br>
<br>
        myFile = os.path.join(os.path.dirname(__file__), template)<br>
        myTemplateFile = file(myFile, 'rt')<br>
        myTemplateContent = myTemplateFile.read()<br>
        myTemplateFile.close()<br>
        myDocument = QDomDocument()<br>
        myDocument.setContent(myTemplateContent)<br>
        myComposition.loadFromTemplate(myDocument)<br>
<br>
        # Get map composition and define scale<br>
        myAtlasMap = myComposition.getComposerMapById(0)<br>
        myAtlasMap.setNewScale(int(scale))<br>
<br>
        # Setup Atlas<br>
        myAtlas = QgsAtlasComposition(myComposition)<br>
        myAtlas.setCoverageLayer(atlas_desktop)<br>
        myAtlas.setComposerMap(myAtlasMap)<br>
        myAtlas.setFixedScale(True)<br>
        myAtlas.fixedScale()<br>
        myAtlas.setHideCoverage(False)<br>
        myAtlas.setFilterFeatures(True)<br>
        myAtlas.setFeatureFilter("reference = '%s'" % (str(ref)))<br>
        myAtlas.setFilterFeatures(True)<br>
        print myAtlas.composerMap()<br>
<br>
        # Generate atlas<br>
        myAtlas.beginRender()<br>
        for i in range(0, myAtlas.numFeatures()):<br>
            myAtlas.prepareForFeature( i )<br>
            jobs = r"\\myserver\a folder\Jobs"<br>
            job_fol = os.path.join(jobs, str(ref))<br>
            if not os.path.exists(job_fol):<br>
                os.makedirs(job_fol)<br>
            output_jpeg = os.path.join(job_fol, ref + "_BMS_plan.jpg")<br>
            myImage = myComposition.printPageAsRaster(0)<br>
            myImage.save(output_jpeg)<br>
        myAtlas.endRender()<br>
        if os.path.isfile(output_jpeg) is False:<br>
            QMessageBox.warning(self.iface.mainWindow(), "Uh Oh!",<br>
"Something went wrong, no image exported!")<br>
            return<br>
        else:<br>
            return<br>
<br>
In QGIS 2.2 this script is no longer working correctly. The template is<br>
loaded and a map is exported to image, however, the map does not display the<br>
correct area. The map area draws the correct layers but the extent is wrong<br>
(no where near the feature from the atlas). Had a look at the documentation<br>
and wasn't really able to see what has changed/deprecated?<br>
<br>
Thanks<br>
Matt<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/Atlas-export-Python-script-not-working-in-2-2-tp5106328.html" target="_blank">http://osgeo-org.1560.x6.nabble.com/Atlas-export-Python-script-not-working-in-2-2-tp5106328.html</a><br>

Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div><br></div>