Classes - panickspa/SimilarityPlugin GitHub Wiki

All attribute in this plugin classes

CalculationModule

    killed: bool

        # Statement of task is being killed or not

    layer : class QgsVectorLayer

        # First original layer 

    layerDup : class QgsVectorLayer

        # Clone of the first layer and the first result layer for calculation

    layerResult : class QgsVectorLayer

        # The first result layer

    layer2 : class QgsVectorLayer

        # Second original layer

    layer2Dup : class QgsVectorLayer

        # Clone of the second layer and the second result layer for calculation
    
    layerResult : class QgsVectorLayer

        # The second result layer

     method : int
    
      # Selected method index
    
     radius : float

      # Radius for NN method

    similarLayer : list=[]

      #Result of similarity calculation, Zero index is the first feature id in first layer, First index is the second feature id in second layer, Second index is the score of similarity

     suffix : str

      # Suffix for Cloned layer name

     scoreName : str

      # Attribute name for reserving score information in cloned layer

    translate : bool

      # Statement for checking method is translated or not for Wilkerstat method

    treshold : float
    
      # Determined treshold

    def setTreshold(self, treshold:float)
      """"
      Threshold option
      """
      float treshold # determined treshold
      return None

    def setLayers(self, layer:QgsVectorLayer, layer2:QgsVectorLayer)
      """
      Set the original layers
      """
      class QgsVectorLayer layer # The first original layer 
      class QgsVectorLayer layer2 # The second original layer 
      return None

    def setMethod(self, method:int)
      """
      Set method attribute
      """
      class int method # Selected method index
      return None

    def setTranslate(self, translate:bool)
      """
      Set translate attribute
      """

      bool translate # Translate Statement
      return None

   def setRadius(self, radius:float)
      """
      Set the radius attribute
      """

      float radius # Determined radius from user
      return None

   def setSuffix(self, suffix:str)
      """
      Set suffix attribute
      """

      str suffix  # suffix name for duplicated layer
   
   def setScoreName(self, scoreName:str)
      """
      Set scoreName attribute
      """
      str suffix # socre name attribute for duplicated layer
   
   def:getSimilarLayer(self)
      """
      get similar layer result list
      """

      return self.similarLayer # list
   
   def getLayers(self)
      """
      get the original layer
      """
      return [self.layer, self.layer2] # The list
   
   def getLayersDup(self)
      """
      get duplicated layer
      """
      return list [self.layerDup, self.layer2Dup] # The list
   
   def setLayer(self, layer:QgsVectorLayer, layer2:QgsVectorLayer)
      """
      Set the original layers
      """
      class QgsVectorLayer layer # The first layer
      class QgsVectorLayer layer2 # The second layer
      return None
      
   def duplicateLayer(self, currentLayer:QgsVectorLayer, suffix:str, scoreName:str)
      """
      Duplicating layer and stored to temporary layer
      """
      class QgsVectorLayer currentLayer # Layer target
      str suffix # suffix name layer
      str scoreName # score name attribute in layer
      return QgsVectorLayer
   
   def __addFeatureResult(self, feature:QgsFeature, feature2:QgsFeature, score:float)

      # Adding result feature to result layer

      # Parameters

        QgsFeature feature # the first feature
        QgsFeature featuer2 # the second feature
        float score # the similarity score

   def __calcMapCurvesGeom(self, g:QgsGeometry, g2:QgsGeometry)

        # Calculate the score between the geometry in float number using GOF Mapcurves (Hargrove et al. 2006)
   
        # Parameters
   
        feature : class QgsFeature # First feature input

        feature2 : class QgsFeature # Second feature input
         
        return null

   def __calcMapCurves(self, feature:QgsFeature, feature2:QgsFeature)

        # Calculate the score and save to self.similarLayer. Score saved in float number using GOF Mapcurves (Hargrove et al. 2006)
   
        # Parameters
   
        feature : class QgsFeature # First feature input

        feature2 : class QgsFeature # Second feature input
         
        return null
   
   def __calculateSq(self, layer:QgsVectorLayer, layer2:QgsVectorLayer)

        # Checking similarity between two layer with squential method 

        # Parameters
   
        layer : class QgsVectorLayer # First layer input

        layer2 : class QgsVectorLayer # Second layer input
         
        return null
   
   def __calculateKNN(self, layer:QgsVectorLayer, layer2:QgsVectorLayer)

        # Check each feature between 2 layer within radius bounding box. Radius distance using euclidean.

        # Parameters
   
        layer : class QgsVectorLayer # First layer input`

        layer2 : class QgsVectorLayer # Second layer input`
         
        return null

   def __calculateWK(self, layer:QgsVectorLayer, layer2:QgsVectorLayer)

        # Checking similarity with matching the primary key each feature in layers, see https://sig.bps.go.id/
   
        # Parameters
   
        layer : class QgsVectorLayer # First layer input`

        layer2 : class QgsVectorLayer # Second layer input`
         
        return null

   def translateCenterGeom(self, g:QgsGeometry, target:QgsGeometry) #
   
        # Translate first geometry to the center of target geometry

        # Parameters
   
        layer : class QgsGeometry # First layer input

        layer2 : class QgsGeometry # Second layer input`
         
        return null
   

Class: SimilarityPlugin


   layer : class QgsVectorLayer

      #  The first layer

   layer2 : class QgsVectorLayer

      #  The second layer

   iface : iface

      # Save reference to the QGIS interface

   plugin_dir : str

      # initialize plugin directory

   dlg : class SimilarityPluginDialog

      # Main plugin dialog

   similarLayer : list = [] 

      # The result of calculation process

   previewLayer : int = 0

      # Current index similarLayer that previewed in canvas

   def tr(self, message)
      """Get the translation for a string using Qt translation API.

      We implement this ourselves since we do not inherit QObject.

      :param message: String for translation.
      :type message: str, QString

      :returns: Translated version of message.
      :rtype: QString
      """
      # noinspection PyTypeChecker,PyArgumentList,PyCallByClass
      return QCoreApplication.translate('SimilarityPlugin', message)
   
    def add_action(
        self,
        icon_path,
        text,
        callback,
        enabled_flag=True,
        add_to_menu=True,
        add_to_toolbar=True,
        status_tip=None,
        whats_this=None,
        parent=None)

      """Add a toolbar icon to the toolbar.

        :param icon_path: Path to the icon for this action. Can be a resource
            path (e.g. ':/plugins/foo/bar.png') or a normal file system path.
        :type icon_path: str

        :param text: Text that should be shown in menu items for this action.
        :type text: str

        :param callback: Function to be called when the action is triggered.
        :type callback: function

        :param enabled_flag: A flag indicating if the action should be enabled
            by default. Defaults to True.
        :type enabled_flag: bool

        :param add_to_menu: Flag indicating whether the action should also
            be added to the menu. Defaults to True.
        :type add_to_menu: bool

        :param add_to_toolbar: Flag indicating whether the action should also
            be added to the toolbar. Defaults to True.
        :type add_to_toolbar: bool

        :param status_tip: Optional text to show in a popup when mouse pointer
            hovers over the action.
        :type status_tip: str

        :param parent: Parent widget for the new action. Defaults None.
        :type parent: QWidget

        :param whats_this: Optional text to show in the status bar when the
            mouse pointer hovers over the action.

        :returns: The action that was created. Note that the action is also
            added to self.actions list.
        :rtype: QAction
        """

   def initGui(self)
      """Create the menu entries and toolbar icons inside the QGIS GUI."""
   
   def unload(self)
      """Removes the plugin menu item and icon from QGIS GUI."""

   def methodChange(self)

      # Change on interaction method combo box
   
   def resultPreview(self)

      #  Activate preview section

   def attrPrinter(self, fieldList: object, feature: QgsFeature, place: QTextEdit)

      # Print feature atrribute info on text edit in preview section

      # Parameters:
            
         fieldList : object  # Iterable field value object

         feature : class QgsFeature # The feature will be printed

         place : class QTextEdit # The place atrribute will be printed

   def refreshPreview(self)

      # redraw Canvas preview

   def nextPreview(self)

      # next result features

   def nextPrevious(self)

      # previous result features

   def rmFeatResult(self)

      # Remove the current result

   def rmWarn(self)

      # Warning dialog to prevent accidentally remove result

   def registerToProject(self)

      # Interaction when self.dlg.saveBtn clicked

   def finishedCalcThread(self, itemVal)

      # Signal when self.calcTask finished

   def stopCalcThread(self)

      # Signal when self.calcThread stopped

   def errorCalcThread(self)
      
      # Signal when self.calcTask error
   
   def setLayers(self, layers:list)

      # Set the layers attribut

      # Parameters
      list layers=[QgsVectorLayer, QgsVectorLayer]:
      return None

Class: SimilarityPluginDialog

   attrOutlineEdit : class QLineEdit

      # Inputation interface for attribute name score in attribute table in string (text)

   calcBtn : class QPushButton

      # Button for exceuting calculation

   layerSel1 : class QgsMapComboBox

      # Combo Box for selecting first layer

   layerSel2 : class QgsMapComboBox

      # Combo Box for selecting second layer

   lineEditTreshold : class QDoubleSpinBox

      # Inputation for similarity score treshold in float (number)

   mainTab   : class QWidget

      # Tab for the main menu

   mergeCenterCheck : class QCheckBox

      # Check box for calculation with centering the geometry to another geometry

   methodComboBox : class QCheckBox

      # Combo box for selecting the checking similarity method

   nextBtn : class QPushButton

      # Button for preview the next feature in similarity list result

   nnRadiusEdit : class QDoubleSpinBox

      # Inputation the radius tolerance (The number is according to the projection unit scale)

   sufLineEdit  : class QLineEdit

      # Inputation for suffix result layer name

   previewAttr : class QTextEdit

      # Previewing attribute current feature in first layer

   previewAttr_2 : class QLineEdit

      # Previewing attribute current feature in second layer

   previousBtn : class QPushButton`

      # Button for preview the previous feature in similarity list result

   progressBar : class QProgressBar

      # show the progress calculation

   SimilarityPluginDialogBase : class QDialog

      # Base plugin window dialog

   tabWidget : class QTabWidget

      # Tab widget in the plugin

   widgetCanvas : class QgsMapCanvas

      # Canvas widget in preview section for previewing the result

   stopBtn : class PushButton
      
      # Button for stoping the calculation
   

Class: WarnDialog

   msgLabel : class QLabel

      # The warning message

   noBtn : class QPushButton

      # Button for reject the condition

   yesBtn : class QPushButton

      # Button for accept the condition

Class: SimpleWarningDialog

   msgLabel : class QLabel

      # The warning message

   okBtn : class QPushButton

      # Ok condition