Ejemplo n.º 1
0
  def test02_export_project1(self):
    """test exporting from a test project"""
    projectPath = dataPath("testproject1.qgs")
    mapSettings = loadProject(projectPath)

    # output size
    width = 800
    height = width * mapSettings.extent().height() / mapSettings.extent().width()
    mapSettings.setOutputSize(QSize(width, height))

    exporter = Exporter(None, dataPath("testproject1.qto3settings"))
    exporter.setMapSettings(mapSettings)
    err = exporter.export(outputPath(os.path.join("testproject1", "testproject1.html")))
    assert err == Exporter.NO_ERROR, err

    # test export with flat plane and vector objects
    exporter.settings.data[ObjectTreeItem.ITEM_DEM]["comboBox_DEMLayer"] = 0
    err = exporter.export(outputPath(os.path.join("testproject1", "flatplane.html")))
    assert err == Exporter.NO_ERROR, err
Ejemplo n.º 2
0
  def test01_export_empty(self):
    """test exporting with empty export settings"""
    # map settings
    canvasSize = QSize(600, 600)
    width = 1000.
    height = width * canvasSize.height() / canvasSize.width()
    crs = QgsCoordinateReferenceSystem(3099, QgsCoordinateReferenceSystem.EpsgCrsId)  # JGD2000 / UTM zone 53N

    mapSettings = QgsMapSettings()
    mapSettings.setOutputSize(canvasSize)
    mapSettings.setExtent(QgsRectangle(0, 0, width, height))
    mapSettings.setDestinationCrs(crs)

    exporter = Exporter()
    exporter.setMapSettings(mapSettings)
    err = exporter.export(outputPath(os.path.join("empty", "empty.html")))
    assert err == Exporter.NO_ERROR, err
Ejemplo n.º 3
0
  def test01_gsielevtile(self):
    """test exporting with GSI elevation tile plugin"""
    projectPath = dataPath("testproject1.qgs")
    mapSettings = loadProject(projectPath)

    # zoom
    mapSettings.setExtent(QgsRectangle(-51698, -75431, 21286, -20179))

    # output size
    width = 800
    height = width * mapSettings.extent().height() / mapSettings.extent().width()
    mapSettings.setOutputSize(QSize(width, height))

    exporter = Exporter(None, dataPath("gsielevtile.qto3settings"))
    exporter.settings.pluginManager = PluginManager(True)   # enables all plugins
    exporter.settings.setMapSettings(mapSettings)
    err = exporter.export(outputPath(os.path.join("testproject1", "gsielevtile.html")))
    assert err == Exporter.NO_ERROR, err
Ejemplo n.º 4
0
  def test01_gsielevtile(self):
    """test exporting with GSI elevation tile plugin"""
    projectPath = dataPath("testproject1.qgs")
    mapSettings = loadProject(projectPath)

    # zoom
    mapSettings.setExtent(QgsRectangle(-51698, -75431, 21286, -20179))

    # output size
    width = 800
    height = width * mapSettings.extent().height() / mapSettings.extent().width()
    mapSettings.setOutputSize(QSize(width, height))

    exporter = Exporter(None, dataPath("gsielevtile.qto3settings"))
    exporter.settings.pluginManager = PluginManager(True)   # enables all plugins
    exporter.settings.setMapSettings(mapSettings)
    err = exporter.export(outputPath(os.path.join("testproject1", "gsielevtile.html")))
    assert err == Exporter.NO_ERROR, err
Ejemplo n.º 5
0
        exporter = Exporter(iface, newSettingPath)
        exporter.setMapSettings(mapSettings)
        #print "exporter instance"
        # Coordinate transform
        center = canvas.center()
        
        # Set extent and rotation
        rotation = 0
        #exporter.setExtent(center, canvas.width(), canvas.height(), rotation)
        exporter.setExtent(center, 700, 500, rotation)
        
        # Output HTML file path
        filepath = path_tmpl.format(filename)
        
        # Export
        err = exporter.export(filepath, openBrowser=False)
        #if err == Exporter.NO_ERROR:
          #print "{0} has been exported to {1}".format(filename, filepath)
        #else:
         # print "Failed to export {0}: {1}".format(filename, err)

        QgsMapLayerRegistry.instance().removeMapLayer(layer.id())
        #canvas.refresh() 
        if i%100 == 0 :
            print i
    

print "tada!"


        "checkBox_Surroundings": False,
        "checkBox_TransparentBackground": False,
        "comboBox_ClipLayer": None,
        "comboBox_DEMLayer": dem.id(),
        "comboBox_TextureSize": 100,
        "horizontalSlider_DEMSize": 2,
        "lineEdit_Color": "",
        "lineEdit_ImageFile": "",
        "lineEdit_centerX": "",
        "lineEdit_centerY": "",
        "lineEdit_rectHeight": "",
        "lineEdit_rectWidth": "",
        "radioButton_MapCanvas": True,
        "radioButton_Simple": True,
        "spinBox_Height": 4,
        "spinBox_Roughening": 4,
        "spinBox_Size": 5,
        "spinBox_demtransp": 0,
        "visible": True
    },
    "OutputFilename": outputPath,
    "PluginVersion": "1.4.2",
    "Template": "3DViewer(dat-gui).html"
}

e = Exporter(iface)
e.settings.loadSettings(props)
canvas = iface.mapCanvas()
e.setMapSettings(canvas.mapSettings())
e.export(outputPath, openBrowser=True)