def setUnits(self, units): self.label.setText(QgsUnitTypes.toString(units)) if QgsUnitTypes.unitType(units) != QgsUnitTypes.Standard: self.units_combo.hide() self.label.show() else: self.units_combo.setCurrentIndex(self.units_combo.findData(units)) self.units_combo.show() self.label.hide() self.warning_label.setVisible(units == QgsUnitTypes.DistanceDegrees) self.base_units = units
def testDistanceUnitType(self): """Test QgsUnitTypes::unitType() """ expected = {QGis.Meters: QgsUnitTypes.Standard, QGis.Feet: QgsUnitTypes.Standard, QGis.Degrees: QgsUnitTypes.Geographic, QGis.UnknownUnit: QgsUnitTypes.UnknownType, QGis.NauticalMiles: QgsUnitTypes.Standard } for t in expected.keys(): self.assertEqual(QgsUnitTypes.unitType(t), expected[t])
def testDistanceUnitType(self): """Test QgsUnitTypes::unitType() """ expected = {QgsUnitTypes.DistanceMeters: QgsUnitTypes.Standard, QgsUnitTypes.DistanceKilometers: QgsUnitTypes.Standard, QgsUnitTypes.DistanceFeet: QgsUnitTypes.Standard, QgsUnitTypes.DistanceYards: QgsUnitTypes.Standard, QgsUnitTypes.DistanceMiles: QgsUnitTypes.Standard, QgsUnitTypes.DistanceDegrees: QgsUnitTypes.Geographic, QgsUnitTypes.DistanceUnknownUnit: QgsUnitTypes.UnknownType, QgsUnitTypes.DistanceNauticalMiles: QgsUnitTypes.Standard } for t in list(expected.keys()): self.assertEqual(QgsUnitTypes.unitType(t), expected[t])
def testAreaUnitType(self): """Test QgsUnitTypes::unitType() for area units """ expected = {QgsUnitTypes.AreaSquareMeters: QgsUnitTypes.Standard, QgsUnitTypes.AreaSquareKilometers: QgsUnitTypes.Standard, QgsUnitTypes.AreaSquareFeet: QgsUnitTypes.Standard, QgsUnitTypes.AreaSquareYards: QgsUnitTypes.Standard, QgsUnitTypes.AreaSquareMiles: QgsUnitTypes.Standard, QgsUnitTypes.AreaHectares: QgsUnitTypes.Standard, QgsUnitTypes.AreaAcres: QgsUnitTypes.Standard, QgsUnitTypes.AreaSquareNauticalMiles: QgsUnitTypes.Standard, QgsUnitTypes.AreaSquareDegrees: QgsUnitTypes.Geographic, QgsUnitTypes.AreaUnknownUnit: QgsUnitTypes.UnknownType, } for t in list(expected.keys()): self.assertEqual(QgsUnitTypes.unitType(t), expected[t])