def test03_SaveRestoreBasemapsFromProject(self):
        """Test saving and restoring enabled basemaps from project"""
        self.assertEqual(WRITER_REGISTRY.getBasemapsFromProject(), [])
        WRITER_REGISTRY.saveBasemapsToProject(['a', 'b c d'])
        self.assertEqual(WRITER_REGISTRY.getBasemapsFromProject(),
                         ['a', 'b c d'])

        # no existing settings
        QgsProject.instance().removeEntry("qgis2web", "/")
        self.assertEqual(WRITER_REGISTRY.getBasemapsFromProject(), [])
Ejemplo n.º 2
0
    def processAlgorithm(self, progress):
        """Here is where the processing itself takes place."""

        # The first thing to do is retrieve the values of the parameters
        # entered by the user
        inputFilename = self.getParameterValue(self.INPUT_LAYER)
        inputLayer = dataobjects.getObjectFromUri(inputFilename)
        inputVisible = self.getParameterValue("VISIBLE")

        inputParams = self.getInputs()

        inputMapFormat = self.getParameterValue("MAP_FORMAT")
        writer = self.getWriter(inputMapFormat)

        writer.params = defaultParams
        self.writerParams(writer, inputParams)
        writer.params["Appearance"][
            "Base layer"] = WRITER_REGISTRY.getBasemapsFromProject()
        writer.layers = [inputLayer]
        writer.groups = {}
        writer.popup = [False]
        writer.visible = [inputVisible]
        writer.json = [False]
        writer.cluster = [False]
        exporter = EXPORTER_REGISTRY.createFromProject()
        write_folder = exporter.exportDirectory()
        writer.write(iface, write_folder)
Ejemplo n.º 3
0
    def processAlgorithm(self, progress):
        """Here is where the processing itself takes place."""

        # The first thing to do is retrieve the values of the parameters
        # entered by the user
        inputFilename = self.getParameterValue(self.INPUT_LAYER)
        inputLayer = dataobjects.getObjectFromUri(inputFilename)
        inputVisible = self.getParameterValue("VISIBLE")
        inputCluster = self.getParameterValue("CLUSTER")
        inputPopup = self.getParameterValue("POPUP")

        popupList = []
        fields = inputPopup.split(",")
        for field in fields:
            fieldList = []
            print field
            k, v = field.split(":")
            fieldList.append(k.strip())
            fieldList.append(v.strip())
            popupList.append(tuple(fieldList))

        inputParams = self.getInputs()

        inputMapFormat = self.getParameterValue("MAP_FORMAT")
        writer = self.getWriter(inputMapFormat)

        # Input layers vales are always a string with its location.
        # That string can be converted into a QGIS object (a
        # QgsVectorLayer in this case) using the
        # processing.getObjectFromUri() method.

        writer.params = defaultParams
        self.writerParams(writer, inputParams)
        writer.params["Appearance"][
            "Base layer"] = WRITER_REGISTRY.getBasemapsFromProject()
        writer.layers = [inputLayer]
        writer.groups = {}
        writer.popup = [OrderedDict(popupList)]
        writer.visible = [inputVisible]
        writer.json = [True]
        writer.cluster = [inputCluster]
        exporter = EXPORTER_REGISTRY.createFromProject()
        write_folder = exporter.exportDirectory()
        writer.write(iface, write_folder)