當前位置: 首頁>>代碼示例>>Python>>正文


Python core.QgsInterval類代碼示例

本文整理匯總了Python中qgis.core.QgsInterval的典型用法代碼示例。如果您正苦於以下問題:Python QgsInterval類的具體用法?Python QgsInterval怎麽用?Python QgsInterval使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了QgsInterval類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testEquality

 def testEquality(self):
     i1 = QgsInterval()
     i2 = QgsInterval()
     self.assertEqual(i1, i2)
     i1 = QgsInterval(5)
     self.assertNotEqual(i1, i2)
     i1.setValid(False)
     i2 = QgsInterval(5)
     self.assertNotEqual(i1, i2)
     i1 = QgsInterval(5)
     self.assertEqual(i1, i2)
     i1.setSeconds(6)
     self.assertNotEqual(i1, i2)
開發者ID:,項目名稱:,代碼行數:13,代碼來源:

示例2: testConversions

 def testConversions(self):
     i = QgsInterval()
     # conversions
     i.setYears(1)
     self.assertEqual(round(i.months()), 12)
     self.assertEqual(round(i.weeks()), 52)
     self.assertEqual(round(i.days()), 365)
     i.setDays(5)
     self.assertEqual(i.hours(), 5 * 24)
     self.assertEqual(i.minutes(), 5 * 24 * 60)
     self.assertEqual(i.seconds(), 5 * 24 * 60 * 60)
開發者ID:,項目名稱:,代碼行數:11,代碼來源:

示例3: testIntervalConstructor

    def testIntervalConstructor(self):
        """ Test QgsInterval constructor """

        # invalid interval
        i = QgsInterval()
        self.assertFalse(i.isValid())
        i.setValid(True)
        self.assertTrue(i.isValid())
        i.setValid(False)
        self.assertFalse(i.isValid())
        # setting a duration should make interval valid
        i.setSeconds(5)
        self.assertTrue(i.isValid())

        # constructor with duration
        i = QgsInterval(56)
        self.assertTrue(i.isValid())
        self.assertEqual(i.seconds(), 56)
開發者ID:,項目名稱:,代碼行數:18,代碼來源:

示例4: testSettersGetters

    def testSettersGetters(self):
        # setters and getters
        i = QgsInterval()
        i.setSeconds(60)
        self.assertTrue(i.isValid())
        self.assertEqual(i.seconds(), 60.0)

        i = QgsInterval()
        i.setMinutes(10)
        self.assertTrue(i.isValid())
        self.assertEqual(i.minutes(), 10.0)

        i = QgsInterval()
        i.setHours(5)
        self.assertTrue(i.isValid())
        self.assertEqual(i.hours(), 5.0)

        i = QgsInterval()
        i.setDays(70)
        self.assertTrue(i.isValid())
        self.assertEqual(i.days(), 70.0)

        i = QgsInterval()
        i.setWeeks(9)
        self.assertTrue(i.isValid())
        self.assertEqual(i.weeks(), 9.0)

        i = QgsInterval()
        i.setMonths(4)
        self.assertTrue(i.isValid())
        self.assertEqual(i.months(), 4.0)

        i = QgsInterval()
        i.setYears(8)
        self.assertTrue(i.isValid())
        self.assertEqual(i.years(), 8.0)
開發者ID:,項目名稱:,代碼行數:36,代碼來源:

示例5: testFromString

 def testFromString(self):
     i = QgsInterval.fromString('1 Year 1 Month 1 Week 1 Hour 1 Minute')
     self.assertTrue(i.isValid())
     self.assertEqual(i.seconds(), 34758060)
     i = QgsInterval.fromString('1 Year, 1 Month, 1 Week, 1 Hour, 1 Minute')
     self.assertTrue(i.isValid())
     self.assertEqual(i.seconds(), 34758060)
     i = QgsInterval.fromString('1 Year; 1 Month; 1 Week; 1 Hour; 1 Minute')
     self.assertTrue(i.isValid())
     self.assertEqual(i.seconds(), 34758060)
     i = QgsInterval.fromString('1 Year. 1 Month. 1 Week. 1 Hour. 1 Minute.')
     self.assertTrue(i.isValid())
     self.assertEqual(i.seconds(), 34758060)
     i = QgsInterval.fromString('2 Years')
     self.assertTrue(i.isValid())
     self.assertEqual(i.years(), 2)
     i = QgsInterval.fromString('30 month')
     self.assertTrue(i.isValid())
     self.assertEqual(i.months(), 30)
     i = QgsInterval.fromString(' 40 MONTHS ')
     self.assertTrue(i.isValid())
     self.assertEqual(i.months(), 40)
     i = QgsInterval.fromString('2.5 weeks')
     self.assertTrue(i.isValid())
     self.assertEqual(i.weeks(), 2.5)
     i = QgsInterval.fromString('2.5 WEEK')
     self.assertTrue(i.isValid())
     self.assertEqual(i.weeks(), 2.5)
     i = QgsInterval.fromString('1 Day')
     self.assertTrue(i.isValid())
     self.assertEqual(i.seconds(), 24 * 60 * 60)
     i = QgsInterval.fromString('2  dAys')
     self.assertTrue(i.isValid())
     self.assertEqual(i.seconds(), 48 * 60 * 60)
     i = QgsInterval.fromString('1 hours')
     self.assertTrue(i.isValid())
     self.assertEqual(i.hours(), 1)
     i = QgsInterval.fromString('1.7 HoURS ')
     self.assertTrue(i.isValid())
     self.assertEqual(i.hours(), 1.7)
     i = QgsInterval.fromString('2 minutes')
     self.assertTrue(i.isValid())
     self.assertEqual(i.minutes(), 2)
     i = QgsInterval.fromString('123 MiNuTe ')
     self.assertTrue(i.isValid())
     self.assertEqual(i.minutes(), 123)
     i = QgsInterval.fromString('5 Seconds')
     self.assertTrue(i.isValid())
     self.assertEqual(i.seconds(), 5)
     i = QgsInterval.fromString('5 second')
     self.assertTrue(i.isValid())
     self.assertEqual(i.seconds(), 5)
     i = QgsInterval.fromString('bad')
     self.assertFalse(i.isValid())
開發者ID:,項目名稱:,代碼行數:54,代碼來源:


注:本文中的qgis.core.QgsInterval類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。