예제 #1
0
 def translateForeign(self, txt):
     if len(txt) > 0:
         mlb = TrLib.ImportLabel(txt)
         if mlb is not None and len(mlb) > 0:
             self.ui.txt_mlb.setText(mlb)
             descr = TrLib.DescribeLabel(mlb)
             self.ui.lbl_system_info.setText("System: " + descr)
             return
     self.ui.lbl_system_info.setText("System: No translation")
     self.ui.txt_mlb.setText("No translation")
예제 #2
0
    def onMLB(self):
        mlb = str(self.ui.txt_mlb.text())
        if len(mlb) > 0:
            descr = TrLib.DescribeLabel(mlb)
            wkt = TrLib.ExportLabel(mlb, "WKT")
            epsg = TrLib.ExportLabel(mlb, "EPSG")
            proj4 = TrLib.ExportLabel(mlb, "PROJ4")

            if wkt is not None and len(wkt) > 0:
                self.ui.txt_wkt.setText(wkt)
            else:
                self.ui.txt_wkt.setText("No translation")
            if epsg is not None and len(epsg) > 0:
                self.ui.txt_epsg.setText(epsg)
            else:
                self.ui.txt_epsg.setText("No translation")
            if proj4 is not None and len(proj4) > 0:
                self.ui.txt_proj4.setText(proj4)
            else:
                self.ui.txt_proj4.setText("No translation")
            self.ui.lbl_system_info.setText("System: " + descr)
예제 #3
0
 def onBshlmSystemChanged(self, called_by_index_change=True):
     if not self._handle_system_change:
         return
     self.clearOutput()
     self.cache.is_valid = False  # signal no valid output YET!
     # will only be set to true if nothing goes wrong below....
     self.cache.valid_label = False
     is_custom = self.chb_bshlm_custom_ellipsoid.isChecked()
     self.logBshlm("", clear=True)
     if (is_custom):
         self.cache.is_custom = True
         self.cache.mlb = "custom"
         ell_data, msg = WidgetUtils.getInput(
             [self.txt_bshlm_axis, self.txt_bshlm_flattening], False)
         if len(ell_data) != 2 or ell_data[0] < 0 or ell_data[1] < 0:
             self.logBshlm("Bad ellipsoid data:\n%s" % msg, "red")
             self.cache.valid_label = False
             return
         self.cache.axis = ell_data[0]
         self.cache.flattening = ell_data[1]
         self.cache.valid_label = True
     else:
         self.cache.is_custom = False
         mlb = str(self.cb_bshlm_system.currentText())
         if len(mlb) == 0:
             return
         self.cache.mlb = mlb
         text = TrLib.DescribeLabel(mlb)
         self.lbl_bshlm_description.setText("%s" % text)
         labels = Minilabel.getSystemLabels(mlb)
         if labels is not None:
             for i in range(2):
                 self.input_labels_bshlm[i].setText(labels[i])
         if Minilabel.isProjWeaklyDefined(mlb):
             self.cache.proj_weakly_defined = True
             self.logBshlm(
                 "INFO: distance and azimuths will be calculated in ED50 datum", "blue")
             name, a, f = self.ed50_ellipsoid
             self.cache.geo_mlb = "geo_ed50"
         else:
             try:
                 dtm = TrLib.GetDatum(mlb)
                 name, a, f = TrLib.GetEllipsoidParametersFromDatum(dtm)
                 self.cache.geo_mlb = TrLib.Convert2Geo(mlb)
             except Exception, msg:
                 self.logBshlm("Invalid label:\n%s" % msg, "red")
                 if called_by_index_change:  # if called by handler which adds label to list
                     self._handle_system_change = False
                     self.cb_bshlm_system.removeItem(
                         self.cb_bshlm_system.currentIndex())
                     self.cb_bshlm_system.setEditText(mlb)
                     self._handle_system_change = True
                 return
         if name is not None:
             self.txt_bshlm_ellipsoid.setText(name)
             self.txt_bshlm_axis.setText("%.4f m" % a)
             if 0 < f < 1:
                 sf = 1 / f
             else:
                 sf = f
             self.txt_bshlm_flattening.setText("%.8f" % sf)
             self.cache.flattening = f
             self.cache.axis = a
             self.cache.ellipsoid = name
             self.cache.valid_label = True
         else:
             self.logBshlm(
                 "Invalid input label - unable to set ellipsoid data...", "red")
             if called_by_index_change:  # if called by handler which adds label to list
                 self._handle_system_change = False
                 self.cb_bshlm_system.removeItem(
                     self.cb_bshlm_system.currentIndex())
                 self.cb_bshlm_system.setEditText(mlb)
                 self._handle_system_change = True
             self.txt_bshlm_flattening.setText("")
             self.txt_bshlm_axis.setText("")
             self.cache.valid_label = False