Exemple #1
0
def test_tgeompointseq_accessors(cursor, expected_tgeompointseq):
    assert TGeomPointSeq(expected_tgeompointseq).srid == 4326
    assert TGeomPointSeq(expected_tgeompointseq).tempSubtype() == 'Sequence'
    assert TGeomPointSeq(expected_tgeompointseq).getValues == LineString(
        [Point(10.0, 10.0),
         Point(20.0, 20.0),
         Point(10.0, 10.0)])
    assert TGeomPointSeq(expected_tgeompointseq).startValue == Point(
        10.0, 10.0)
    assert TGeomPointSeq(expected_tgeompointseq).endValue == Point(10.0, 10.0)
    assert TGeomPointSeq(expected_tgeompointseq).getTime == PeriodSet(
        '{[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]}')
    assert TGeomPointSeq(expected_tgeompointseq).duration == timedelta(2)
    assert TGeomPointSeq(expected_tgeompointseq).timespan == timedelta(2)
    assert TGeomPointSeq(expected_tgeompointseq).period == Period(
        '[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]')
    assert TGeomPointSeq(expected_tgeompointseq).numInstants == 3
    assert TGeomPointSeq(
        expected_tgeompointseq).startInstant == TGeomPointInst(
            'Point(10.0 10.0)@2019-09-01 00:00:00+01')
    assert TGeomPointSeq(expected_tgeompointseq).endInstant == TGeomPointInst(
        'Point(10.0 10.0)@2019-09-03 00:00:00+01')
    assert TGeomPointSeq(expected_tgeompointseq).instantN(2) == TGeomPointInst(
        'Point(20.0 20.0)@2019-09-02 00:00:00+01')
    assert TGeomPointSeq(expected_tgeompointseq).instants == \
           [TGeomPointInst('Point(10.0 10.0)@2019-09-01 00:00:00+01'),
            TGeomPointInst('Point(20.0 20.0)@2019-09-02 00:00:00+01'),
            TGeomPointInst('Point(10.0 10.0)@2019-09-03 00:00:00+01')]
    assert TGeomPointSeq(expected_tgeompointseq).numTimestamps == 3
    assert TGeomPointSeq(expected_tgeompointseq).startTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TGeomPointSeq(expected_tgeompointseq).endTimestamp == parse(
        '2019-09-03 00:00:00+01')
    assert TGeomPointSeq(expected_tgeompointseq).timestampN(2) == parse(
        '2019-09-02 00:00:00+01')
    assert TGeomPointSeq(expected_tgeompointseq).timestamps == [
        parse('2019-09-01 00:00:00+01'),
        parse('2019-09-02 00:00:00+01'),
        parse('2019-09-03 00:00:00+01')
    ]
    assert TGeomPointSeq(expected_tgeompointseq).intersectsTimestamp(
        parse('2019-09-01 00:00:00+01')) == True
    assert TGeomPointSeq(expected_tgeompointseq).intersectsTimestamp(
        parse('2019-09-04 00:00:00+01')) == False
    assert TGeomPointSeq(expected_tgeompointseq).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TGeomPointSeq(expected_tgeompointseq).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False
    assert TGeomPointSeq(expected_tgeompointseq).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TGeomPointSeq(expected_tgeompointseq).intersectsPeriod(
        Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False
    assert TGeomPointSeq(expected_tgeompointseq).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TGeomPointSeq(expected_tgeompointseq).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
Exemple #2
0
def test_ttextinst_accessors(cursor, expected_ttextinst):
    assert TTextInst(expected_ttextinst).duration() == 'Instant'
    assert TTextInst(expected_ttextinst).getValue == 'AA'
    assert TTextInst(expected_ttextinst).getValues == ['AA']
    assert TTextInst(expected_ttextinst).startValue == 'AA'
    assert TTextInst(expected_ttextinst).endValue == 'AA'
    assert TTextInst(expected_ttextinst).minValue == 'AA'
    assert TTextInst(expected_ttextinst).maxValue == 'AA'
    assert TTextInst(expected_ttextinst).getTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TTextInst(expected_ttextinst).getTime == PeriodSet(
        '{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]}')
    assert TTextInst(expected_ttextinst).timespan == timedelta(0)
    assert TTextInst(expected_ttextinst).period == Period(
        '[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]')
    assert TTextInst(expected_ttextinst).numInstants == 1
    assert TTextInst(expected_ttextinst).startInstant == TTextInst(
        'AA@2019-09-01 00:00:00+01')
    assert TTextInst(expected_ttextinst).endInstant == TTextInst(
        'AA@2019-09-01 00:00:00+01')
    assert TTextInst(expected_ttextinst).instantN(1) == TTextInst(
        'AA@2019-09-01 00:00:00+01')
    assert TTextInst(expected_ttextinst).instants == [
        TTextInst('AA@2019-09-01 00:00:00+01')
    ]
    assert TTextInst(expected_ttextinst).numTimestamps == 1
    assert TTextInst(expected_ttextinst).startTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TTextInst(expected_ttextinst).endTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TTextInst(expected_ttextinst).timestampN(1) == parse(
        '2019-09-01 00:00:00+01')
    assert TTextInst(expected_ttextinst).timestamps == [
        parse('2019-09-01 00:00:00+01')
    ]
    assert TTextInst(expected_ttextinst).intersectsTimestamp(
        parse('2019-09-01 00:00:00+01')) == True
    assert TTextInst(expected_ttextinst).intersectsTimestamp(
        parse('2019-09-02 00:00:00+01')) == False
    assert TTextInst(expected_ttextinst).intersectsTimestampset(
        TimestampSet(
            '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TTextInst(expected_ttextinst).intersectsTimestampset(
        TimestampSet(
            '{2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01}')) == False
    assert TTextInst(expected_ttextinst).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TTextInst(expected_ttextinst).intersectsPeriod(
        Period('(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == False
    assert TTextInst(expected_ttextinst).intersectsPeriod(
        Period('[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]')) == False
    assert TTextInst(expected_ttextinst).intersectsPeriodset(
        PeriodSet(
            '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TTextInst(expected_ttextinst).intersectsPeriodset(
        PeriodSet(
            '{(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == False
    assert TTextInst(expected_ttextinst).intersectsPeriodset(
        PeriodSet(
            '{[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]}')) == False
Exemple #3
0
def test_tboolinst_accessors(cursor, expected_tboolinst):
    assert TBoolInst(expected_tboolinst).tempSubtype() == 'Instant'
    assert TBoolInst(expected_tboolinst).getValue == True
    assert TBoolInst(expected_tboolinst).getValues == [True]
    assert TBoolInst(expected_tboolinst).startValue == True
    assert TBoolInst(expected_tboolinst).endValue == True
    assert TBoolInst(expected_tboolinst).getTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TBoolInst(expected_tboolinst).getTime == PeriodSet(
        '{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]}')
    assert TBoolInst(expected_tboolinst).duration == timedelta(0)
    assert TBoolInst(expected_tboolinst).timespan == timedelta(0)
    assert TBoolInst(expected_tboolinst).period == Period(
        '[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]')
    assert TBoolInst(expected_tboolinst).numInstants == 1
    assert TBoolInst(expected_tboolinst).startInstant == TBoolInst(
        'true@2019-09-01 00:00:00+01')
    assert TBoolInst(expected_tboolinst).endInstant == TBoolInst(
        'true@2019-09-01 00:00:00+01')
    assert TBoolInst(expected_tboolinst).instantN(1) == TBoolInst(
        'true@2019-09-01 00:00:00+01')
    assert TBoolInst(expected_tboolinst).instants == [
        TBoolInst('true@2019-09-01 00:00:00+01')
    ]
    assert TBoolInst(expected_tboolinst).numTimestamps == 1
    assert TBoolInst(expected_tboolinst).startTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TBoolInst(expected_tboolinst).endTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TBoolInst(expected_tboolinst).timestampN(1) == parse(
        '2019-09-01 00:00:00+01')
    assert TBoolInst(expected_tboolinst).timestamps == [
        parse('2019-09-01 00:00:00+01')
    ]
    assert TBoolInst(expected_tboolinst).intersectsTimestamp(
        parse('2019-09-01 00:00:00+01')) == True
    assert TBoolInst(expected_tboolinst).intersectsTimestamp(
        parse('2019-09-02 00:00:00+01')) == False
    assert TBoolInst(expected_tboolinst).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TBoolInst(expected_tboolinst).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01}')) == False
    assert TBoolInst(expected_tboolinst).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TBoolInst(expected_tboolinst).intersectsPeriod(
        Period('(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == False
    assert TBoolInst(expected_tboolinst).intersectsPeriod(
        Period('[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]')) == False
    assert TBoolInst(expected_tboolinst).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TBoolInst(expected_tboolinst).intersectsPeriodSet(
        PeriodSet(
            '{(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == False
    assert TBoolInst(expected_tboolinst).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]}')) == False
Exemple #4
0
def test_tintseq_accessors(cursor, expected_tintseq):
    assert TIntSeq(expected_tintseq).tempSubtype() == 'Sequence'
    assert TIntSeq(expected_tintseq).getValues == [10, 20, 30]
    assert TIntSeq(expected_tintseq).startValue == 10
    assert TIntSeq(expected_tintseq).endValue == 30
    assert TIntSeq(expected_tintseq).minValue == 10
    assert TIntSeq(expected_tintseq).maxValue == 30
    assert TIntSeq(expected_tintseq).valueRange == intrange(10,
                                                            30,
                                                            upper_inc=True)
    assert TIntSeq(expected_tintseq).getTime == PeriodSet(
        '{[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]}')
    assert TIntSeq(expected_tintseq).duration == timedelta(2)
    assert TIntSeq(expected_tintseq).timespan == timedelta(2)
    assert TIntSeq(expected_tintseq).period == Period(
        '[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]')
    assert TIntSeq(expected_tintseq).numInstants == 3
    assert TIntSeq(expected_tintseq).startInstant == TIntInst(
        '10@2019-09-01 00:00:00+01')
    assert TIntSeq(expected_tintseq).endInstant == TIntInst(
        '30@2019-09-03 00:00:00+01')
    assert TIntSeq(expected_tintseq).instantN(2) == TIntInst(
        '20@2019-09-02 00:00:00+01')
    assert TIntSeq(expected_tintseq).instants == \
           [TIntInst('10@2019-09-01 00:00:00+01'), TIntInst('20@2019-09-02 00:00:00+01'),
            TIntInst('30@2019-09-03 00:00:00+01')]
    assert TIntSeq(expected_tintseq).numTimestamps == 3
    assert TIntSeq(expected_tintseq).startTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TIntSeq(expected_tintseq).endTimestamp == parse(
        '2019-09-03 00:00:00+01')
    assert TIntSeq(expected_tintseq).timestampN(2) == parse(
        '2019-09-02 00:00:00+01')
    assert TIntSeq(expected_tintseq).timestamps == [
        parse('2019-09-01 00:00:00+01'),
        parse('2019-09-02 00:00:00+01'),
        parse('2019-09-03 00:00:00+01')
    ]
    assert TIntSeq(expected_tintseq).intersectsTimestamp(
        parse('2019-09-01 00:00:00+01')) == True
    assert TIntSeq(expected_tintseq).intersectsTimestamp(
        parse('2019-09-04 00:00:00+01')) == False
    assert TIntSeq(expected_tintseq).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TIntSeq(expected_tintseq).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False
    assert TIntSeq(expected_tintseq).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TIntSeq(expected_tintseq).intersectsPeriod(
        Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False
    assert TIntSeq(expected_tintseq).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TIntSeq(expected_tintseq).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
def test_ttextseq_accessors(cursor, expected_ttextseqseteq):
    assert TTextSeq(expected_ttextseqseteq).tempSubtype() == 'Sequence'
    assert TTextSeq(expected_ttextseqseteq).getValues == ['AA', 'BB', 'CC']
    assert TTextSeq(expected_ttextseqseteq).startValue == 'AA'
    assert TTextSeq(expected_ttextseqseteq).endValue == 'CC'
    assert TTextSeq(expected_ttextseqseteq).minValue == 'AA'
    assert TTextSeq(expected_ttextseqseteq).maxValue == 'CC'
    assert TTextSeq(expected_ttextseqseteq).getTime == PeriodSet(
        '{[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]}')
    assert TTextSeq(expected_ttextseqseteq).duration == timedelta(2)
    assert TTextSeq(expected_ttextseqseteq).timespan == timedelta(2)
    assert TTextSeq(expected_ttextseqseteq).period == Period(
        '[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]')
    assert TTextSeq(expected_ttextseqseteq).numInstants == 3
    assert TTextSeq(expected_ttextseqseteq).startInstant == TTextInst(
        'AA@2019-09-01 00:00:00+01')
    assert TTextSeq(expected_ttextseqseteq).endInstant == TTextInst(
        'CC@2019-09-03 00:00:00+01')
    assert TTextSeq(expected_ttextseqseteq).instantN(2) == TTextInst(
        'BB@2019-09-02 00:00:00+01')
    assert TTextSeq(expected_ttextseqseteq).instants == \
           [TTextInst('AA@2019-09-01 00:00:00+01'), TTextInst('BB@2019-09-02 00:00:00+01'),
            TTextInst('CC@2019-09-03 00:00:00+01')]
    assert TTextSeq(expected_ttextseqseteq).numTimestamps == 3
    assert TTextSeq(expected_ttextseqseteq).startTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TTextSeq(expected_ttextseqseteq).endTimestamp == parse(
        '2019-09-03 00:00:00+01')
    assert TTextSeq(expected_ttextseqseteq).timestampN(2) == parse(
        '2019-09-02 00:00:00+01')
    assert TTextSeq(expected_ttextseqseteq).timestamps == [
        parse('2019-09-01 00:00:00+01'),
        parse('2019-09-02 00:00:00+01'),
        parse('2019-09-03 00:00:00+01')
    ]
    assert TTextSeq(expected_ttextseqseteq).intersectsTimestamp(
        parse('2019-09-01 00:00:00+01')) == True
    assert TTextSeq(expected_ttextseqseteq).intersectsTimestamp(
        parse('2019-09-04 00:00:00+01')) == False
    assert TTextSeq(expected_ttextseqseteq).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TTextSeq(expected_ttextseqseteq).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False
    assert TTextSeq(expected_ttextseqseteq).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TTextSeq(expected_ttextseqseteq).intersectsPeriod(
        Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False
    assert TTextSeq(expected_ttextseqseteq).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TTextSeq(expected_ttextseqseteq).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
Exemple #6
0
def test_tboolseq_accessors(cursor, expected_tboolseq):
    assert TBoolSeq(expected_tboolseq).tempSubtype() == 'Sequence'
    assert TBoolSeq(expected_tboolseq).getValues == [True, False]
    assert TBoolSeq(expected_tboolseq).startValue == True
    assert TBoolSeq(expected_tboolseq).endValue == True
    assert TBoolSeq(expected_tboolseq).getTime == PeriodSet(
        '{[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]}')
    assert TBoolSeq(expected_tboolseq).duration == timedelta(2)
    assert TBoolSeq(expected_tboolseq).timespan == timedelta(2)
    assert TBoolSeq(expected_tboolseq).period == Period(
        '[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]')
    assert TBoolSeq(expected_tboolseq).numInstants == 3
    assert TBoolSeq(expected_tboolseq).startInstant == TBoolInst(
        'true@2019-09-01 00:00:00+01')
    assert TBoolSeq(expected_tboolseq).endInstant == TBoolInst(
        'true@2019-09-03 00:00:00+01')
    assert TBoolSeq(expected_tboolseq).instantN(2) == TBoolInst(
        'false@2019-09-02 00:00:00+01')
    assert TBoolSeq(expected_tboolseq).instants == \
           [TBoolInst('true@2019-09-01 00:00:00+01'), TBoolInst('false@2019-09-02 00:00:00+01'),
            TBoolInst('true@2019-09-03 00:00:00+01')]
    assert TBoolSeq(expected_tboolseq).numTimestamps == 3
    assert TBoolSeq(expected_tboolseq).startTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TBoolSeq(expected_tboolseq).endTimestamp == parse(
        '2019-09-03 00:00:00+01')
    assert TBoolSeq(expected_tboolseq).timestampN(2) == parse(
        '2019-09-02 00:00:00+01')
    assert TBoolSeq(expected_tboolseq).timestamps == [
        parse('2019-09-01 00:00:00+01'),
        parse('2019-09-02 00:00:00+01'),
        parse('2019-09-03 00:00:00+01')
    ]
    assert TBoolSeq(expected_tboolseq).intersectsTimestamp(
        parse('2019-09-01 00:00:00+01')) == True
    assert TBoolSeq(expected_tboolseq).intersectsTimestamp(
        parse('2019-09-04 00:00:00+01')) == False
    assert TBoolSeq(expected_tboolseq).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TBoolSeq(expected_tboolseq).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False
    assert TBoolSeq(expected_tboolseq).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TBoolSeq(expected_tboolseq).intersectsPeriod(
        Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False
    assert TBoolSeq(expected_tboolseq).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TBoolSeq(expected_tboolseq).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
Exemple #7
0
def test_tgeompointseqset_accessors(cursor, expected_tgeompointseqset):
    assert TGeomPointSeqSet(expected_tgeompointseqset).srid == 4326
    assert TGeomPointSeqSet(expected_tgeompointseqset).tempSubtype() == 'SequenceSet'
    assert TGeomPointSeqSet(expected_tgeompointseqset).getValues == \
        GeometryCollection([Point(10.0, 10.0), LineString([Point(20.0, 20.0), Point(30.0, 30.0)])])
    assert TGeomPointSeqSet(expected_tgeompointseqset).startValue == Point(10.0, 10.0)
    assert TGeomPointSeqSet(expected_tgeompointseqset).endValue == Point(30.0, 30.0)
    # assert TGeomPointSeqSet(expected_tgeompointseqset).valueRange == geompointrange(Point(10.0, 10.0), Point(30.0, 30.0), upper_inc=True)
    assert TGeomPointSeqSet(expected_tgeompointseqset).getTime == PeriodSet(
        '{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01],[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]}')
    assert TGeomPointSeqSet(expected_tgeompointseqset).duration == timedelta(1)
    assert TGeomPointSeqSet(expected_tgeompointseqset).timespan == timedelta(2)
    assert TGeomPointSeqSet(expected_tgeompointseqset).period == Period('[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]')
    assert TGeomPointSeqSet(expected_tgeompointseqset).numInstants == 3
    assert TGeomPointSeqSet(expected_tgeompointseqset).startInstant == TGeomPointInst('Point(10.0 10.0)@2019-09-01 00:00:00+01')
    assert TGeomPointSeqSet(expected_tgeompointseqset).endInstant == TGeomPointInst('Point(30.0 30.0)@2019-09-03 00:00:00+01')
    assert TGeomPointSeqSet(expected_tgeompointseqset).instantN(2) == TGeomPointInst('Point(20.0 20.0)@2019-09-02 00:00:00+01')
    assert TGeomPointSeqSet(expected_tgeompointseqset).instants == [TGeomPointInst('Point(10.0 10.0)@2019-09-01 00:00:00+01'),
                                                        TGeomPointInst('Point(20.0 20.0)@2019-09-02 00:00:00+01'),
                                                        TGeomPointInst('Point(30.0 30.0)@2019-09-03 00:00:00+01')]
    assert TGeomPointSeqSet(expected_tgeompointseqset).numTimestamps == 3
    assert TGeomPointSeqSet(expected_tgeompointseqset).startTimestamp == parse('2019-09-01 00:00:00+01')
    assert TGeomPointSeqSet(expected_tgeompointseqset).endTimestamp == parse('2019-09-03 00:00:00+01')
    assert TGeomPointSeqSet(expected_tgeompointseqset).timestampN(2) == parse('2019-09-02 00:00:00+01')
    assert TGeomPointSeqSet(expected_tgeompointseqset).timestamps == [parse('2019-09-01 00:00:00+01'),
                                                          parse('2019-09-02 00:00:00+01'),
                                                          parse('2019-09-03 00:00:00+01')]
    assert TGeomPointSeqSet(expected_tgeompointseqset).numSequences == 2
    assert TGeomPointSeqSet(expected_tgeompointseqset).startSequence == TGeomPointSeq('[Point(10.0 10.0)@2019-09-01 00:00:00+01]')
    assert TGeomPointSeqSet(expected_tgeompointseqset).endSequence == TGeomPointSeq(
        '[Point(20.0 20.0)@2019-09-02 00:00:00+01, Point(30.0 30.0)@2019-09-03 00:00:00+01]')
    assert TGeomPointSeqSet(expected_tgeompointseqset).sequenceN(2) == TGeomPointSeq(
        '[Point(20.0 20.0)@2019-09-02 00:00:00+01, Point(30.0 30.0)@2019-09-03 00:00:00+01]')
    assert TGeomPointSeqSet(expected_tgeompointseqset).sequences == [TGeomPointSeq('[Point(10.0 10.0)@2019-09-01 00:00:00+01]'),
        TGeomPointSeq('[Point(20.0 20.0)@2019-09-02 00:00:00+01, Point(30.0 30.0)@2019-09-03 00:00:00+01]')]
    assert TGeomPointSeqSet(expected_tgeompointseqset).intersectsTimestamp(parse('2019-09-01 00:00:00+01')) == True
    assert TGeomPointSeqSet(expected_tgeompointseqset).intersectsTimestamp(parse('2019-09-04 00:00:00+01')) == False
    assert TGeomPointSeqSet(expected_tgeompointseqset).intersectsTimestampSet(
        TimestampSet('{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TGeomPointSeqSet(expected_tgeompointseqset).intersectsTimestampSet(
        TimestampSet('{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False
    assert TGeomPointSeqSet(expected_tgeompointseqset).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TGeomPointSeqSet(expected_tgeompointseqset).intersectsPeriod(
        Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False
    assert TGeomPointSeqSet(expected_tgeompointseqset).intersectsPeriodSet(
        PeriodSet('{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TGeomPointSeqSet(expected_tgeompointseqset).intersectsPeriodSet(
        PeriodSet('{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
 def period(self):
     """
     Period on which the temporal value is defined ignoring the potential
     time gaps.
     """
     return Period(self.startTimestamp, self.endTimestamp,
                   self._sequenceList[0]._lower_inc,
                   self._sequenceList[-1]._upper_inc)
Exemple #9
0
def test_tgeompointinst_accessors(cursor, expected_tgeompointinst):
    assert TGeomPointInst(expected_tgeompointinst).srid == 4326
    assert TGeomPointInst(expected_tgeompointinst).duration() == 'Instant'
    assert TGeomPointInst(expected_tgeompointinst).getValue == Point(10.0, 10.0)
    assert TGeomPointInst(expected_tgeompointinst).getValues == Point(10.0, 10.0)
    assert TGeomPointInst(expected_tgeompointinst).startValue == Point(10.0, 10.0)
    assert TGeomPointInst(expected_tgeompointinst).endValue == Point(10.0, 10.0)
    assert TGeomPointInst(expected_tgeompointinst).getTimestamp == parse('2019-09-01 00:00:00+01')
    assert TGeomPointInst(expected_tgeompointinst).getTime == PeriodSet(
        '{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]}')
    assert TGeomPointInst(expected_tgeompointinst).timespan == timedelta(0)
    assert TGeomPointInst(expected_tgeompointinst).period == Period(
        '[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]')
    assert TGeomPointInst(expected_tgeompointinst).numInstants == 1
    assert TGeomPointInst(expected_tgeompointinst).startInstant == TGeomPointInst(
        'Point(10.0 10.0)@2019-09-01 00:00:00+01')
    assert TGeomPointInst(expected_tgeompointinst).endInstant == TGeomPointInst(
        'Point(10.0 10.0)@2019-09-01 00:00:00+01')
    assert TGeomPointInst(expected_tgeompointinst).instantN(1) == TGeomPointInst(
        'Point(10.0 10.0)@2019-09-01 00:00:00+01')
    assert TGeomPointInst(expected_tgeompointinst).instants == [
        TGeomPointInst('Point(10.0 10.0)@2019-09-01 00:00:00+01')]
    assert TGeomPointInst(expected_tgeompointinst).numTimestamps == 1
    assert TGeomPointInst(expected_tgeompointinst).startTimestamp == parse('2019-09-01 00:00:00+01')
    assert TGeomPointInst(expected_tgeompointinst).endTimestamp == parse('2019-09-01 00:00:00+01')
    assert TGeomPointInst(expected_tgeompointinst).timestampN(1) == parse('2019-09-01 00:00:00+01')
    assert TGeomPointInst(expected_tgeompointinst).timestamps == [parse('2019-09-01 00:00:00+01')]
    assert TGeomPointInst(expected_tgeompointinst).intersectsTimestamp(parse('2019-09-01 00:00:00+01')) == True
    assert TGeomPointInst(expected_tgeompointinst).intersectsTimestamp(parse('2019-09-02 00:00:00+01')) == False
    assert TGeomPointInst(expected_tgeompointinst).intersectsTimestampset(
        TimestampSet('{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TGeomPointInst(expected_tgeompointinst).intersectsTimestampset(
        TimestampSet('{2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01}')) == False
    assert TGeomPointInst(expected_tgeompointinst).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TGeomPointInst(expected_tgeompointinst).intersectsPeriod(
        Period('(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == False
    assert TGeomPointInst(expected_tgeompointinst).intersectsPeriod(
        Period('[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]')) == False
    assert TGeomPointInst(expected_tgeompointinst).intersectsPeriodset(
        PeriodSet('{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TGeomPointInst(expected_tgeompointinst).intersectsPeriodset(
        PeriodSet('{(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == False
    assert TGeomPointInst(expected_tgeompointinst).intersectsPeriodset(
        PeriodSet('{[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]}')) == False
Exemple #10
0
def test_tgeompointi_accessors(cursor, expected_tgeompointi):
    assert TGeomPointI(expected_tgeompointi).srid == 4326
    assert TGeomPointI(expected_tgeompointi).duration() == 'InstantSet'
    assert TGeomPointI(expected_tgeompointi).getValues == \
           MultiPoint([Point(10.0, 10.0),Point(20.0, 20.0),Point(30.0, 30.0)])
    assert TGeomPointI(expected_tgeompointi).startValue == Point(10.0, 10.0)
    assert TGeomPointI(expected_tgeompointi).endValue == Point(30.0, 30.0)
    assert TGeomPointI(expected_tgeompointi).getTime == \
           PeriodSet(
               '{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01], [2019-09-02 00:00:00+01, 2019-09-02 00:00:00+01], '
               '[2019-09-03 00:00:00+01, 2019-09-03 00:00:00+01]}')
    assert TGeomPointI(expected_tgeompointi).timespan == timedelta(0)
    assert TGeomPointI(expected_tgeompointi).period == Period('[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]')
    assert TGeomPointI(expected_tgeompointi).numInstants == 3
    assert TGeomPointI(expected_tgeompointi).startInstant == TGeomPointInst('Point(10.0 10.0)@2019-09-01 00:00:00+01')
    assert TGeomPointI(expected_tgeompointi).endInstant == TGeomPointInst('Point(30.0 30.0)@2019-09-03 00:00:00+01')
    assert TGeomPointI(expected_tgeompointi).instantN(2) == TGeomPointInst('Point(20.0 20.0)@2019-09-02 00:00:00+01')
    assert TGeomPointI(expected_tgeompointi).instants == [TGeomPointInst('Point(10.0 10.0)@2019-09-01 00:00:00+01'),
                                                            TGeomPointInst('Point(20.0 20.0)@2019-09-02 00:00:00+01'),
                                                            TGeomPointInst('Point(30.0 30.0)@2019-09-03 00:00:00+01')]
    assert TGeomPointI(expected_tgeompointi).numTimestamps == 3
    assert TGeomPointI(expected_tgeompointi).startTimestamp == parse('2019-09-01 00:00:00+01')
    assert TGeomPointI(expected_tgeompointi).endTimestamp == parse('2019-09-03 00:00:00+01')
    assert TGeomPointI(expected_tgeompointi).timestampN(2) == parse('2019-09-02 00:00:00+01')
    assert TGeomPointI(expected_tgeompointi).timestamps == [parse('2019-09-01 00:00:00+01'),
                                                              parse('2019-09-02 00:00:00+01'),
                                                              parse('2019-09-03 00:00:00+01')]
    assert TGeomPointI(expected_tgeompointi).intersectsTimestamp(parse('2019-09-01 00:00:00+01')) == True
    assert TGeomPointI(expected_tgeompointi).intersectsTimestamp(parse('2019-09-04 00:00:00+01')) == False
    assert TGeomPointI(expected_tgeompointi).intersectsTimestampset(
        TimestampSet('{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TGeomPointI(expected_tgeompointi).intersectsTimestampset(
        TimestampSet('{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False
    assert TGeomPointI(expected_tgeompointi).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TGeomPointI(expected_tgeompointi).intersectsPeriod(
        Period('(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01)')) == False
    assert TGeomPointI(expected_tgeompointi).intersectsPeriod(
        Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False
    assert TGeomPointI(expected_tgeompointi).intersectsPeriodset(
        PeriodSet('{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TGeomPointI(expected_tgeompointi).intersectsPeriodset(
        PeriodSet('{(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01)}')) == False
    assert TGeomPointI(expected_tgeompointi).intersectsPeriodset(
        PeriodSet('{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
def test_tintinst_accessors(cursor, expected_tintinst):
    assert TIntInst(expected_tintinst).tempSubtype() == 'Instant'
    assert TIntInst(expected_tintinst).getValue == 10
    assert TIntInst(expected_tintinst).getValues == [10]
    assert TIntInst(expected_tintinst).startValue == 10
    assert TIntInst(expected_tintinst).endValue == 10
    assert TIntInst(expected_tintinst).minValue == 10
    assert TIntInst(expected_tintinst).maxValue == 10
    assert TIntInst(expected_tintinst).valueRange == intrange(10, 10, upper_inc=True)
    assert TIntInst(expected_tintinst).getTimestamp == parse('2019-09-01 00:00:00+01')
    assert TIntInst(expected_tintinst).getTime == PeriodSet('{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]}')
    assert TIntInst(expected_tintinst).duration == timedelta(0)
    assert TIntInst(expected_tintinst).timespan == timedelta(0)
    assert TIntInst(expected_tintinst).period == Period('[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]')
    assert TIntInst(expected_tintinst).numInstants == 1
    assert TIntInst(expected_tintinst).startInstant == TIntInst('10@2019-09-01 00:00:00+01')
    assert TIntInst(expected_tintinst).endInstant == TIntInst('10@2019-09-01 00:00:00+01')
    assert TIntInst(expected_tintinst).instantN(1) == TIntInst('10@2019-09-01 00:00:00+01')
    assert TIntInst(expected_tintinst).instants == [TIntInst('10@2019-09-01 00:00:00+01')]
    assert TIntInst(expected_tintinst).numTimestamps == 1
    assert TIntInst(expected_tintinst).startTimestamp == parse('2019-09-01 00:00:00+01')
    assert TIntInst(expected_tintinst).endTimestamp == parse('2019-09-01 00:00:00+01')
    assert TIntInst(expected_tintinst).timestampN(1) == parse('2019-09-01 00:00:00+01')
    assert TIntInst(expected_tintinst).timestamps == [parse('2019-09-01 00:00:00+01')]
    assert TIntInst(expected_tintinst).intersectsTimestamp(parse('2019-09-01 00:00:00+01')) == True
    assert TIntInst(expected_tintinst).intersectsTimestamp(parse('2019-09-02 00:00:00+01')) == False
    assert TIntInst(expected_tintinst).intersectsTimestampSet(
        TimestampSet('{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TIntInst(expected_tintinst).intersectsTimestampSet(
        TimestampSet('{2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01}')) == False
    assert TIntInst(expected_tintinst).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TIntInst(expected_tintinst).intersectsPeriod(
        Period('(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == False
    assert TIntInst(expected_tintinst).intersectsPeriod(
        Period('[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]')) == False
    assert TIntInst(expected_tintinst).intersectsPeriodSet(
        PeriodSet('{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TIntInst(expected_tintinst).intersectsPeriodSet(
        PeriodSet('{(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == False
    assert TIntInst(expected_tintinst).intersectsPeriodSet(
        PeriodSet('{[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]}')) == False
def test_tbooli_accessors(cursor, expected_tbooli):
    assert TBoolI(expected_tbooli).duration() == 'InstantSet'
    assert TBoolI(expected_tbooli).getValues == [True, False]
    assert TBoolI(expected_tbooli).startValue == True
    assert TBoolI(expected_tbooli).endValue == True
    assert TBoolI(expected_tbooli).getTime == \
           PeriodSet(
               '{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01], [2019-09-02 00:00:00+01, 2019-09-02 00:00:00+01], '
               '[2019-09-03 00:00:00+01, 2019-09-03 00:00:00+01]}')
    assert TBoolI(expected_tbooli).timespan == timedelta(0)
    assert TBoolI(expected_tbooli).period == Period('[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]')
    assert TBoolI(expected_tbooli).numInstants == 3
    assert TBoolI(expected_tbooli).startInstant == TBoolInst('true@2019-09-01 00:00:00+01')
    assert TBoolI(expected_tbooli).endInstant == TBoolInst('true@2019-09-03 00:00:00+01')
    assert TBoolI(expected_tbooli).instantN(2) == TBoolInst('false@2019-09-02 00:00:00+01')
    assert TBoolI(expected_tbooli).instants == [TBoolInst('true@2019-09-01 00:00:00+01'),
                                                TBoolInst('false@2019-09-02 00:00:00+01'),
                                                TBoolInst('true@2019-09-03 00:00:00+01')]
    assert TBoolI(expected_tbooli).numTimestamps == 3
    assert TBoolI(expected_tbooli).startTimestamp == parse('2019-09-01 00:00:00+01')
    assert TBoolI(expected_tbooli).endTimestamp == parse('2019-09-03 00:00:00+01')
    assert TBoolI(expected_tbooli).timestampN(2) == parse('2019-09-02 00:00:00+01')
    assert TBoolI(expected_tbooli).timestamps == [parse('2019-09-01 00:00:00+01'), parse('2019-09-02 00:00:00+01'),
                                                  parse('2019-09-03 00:00:00+01')]
    assert TBoolI(expected_tbooli).intersectsTimestamp(parse('2019-09-01 00:00:00+01')) == True
    assert TBoolI(expected_tbooli).intersectsTimestamp(parse('2019-09-04 00:00:00+01')) == False
    assert TBoolI(expected_tbooli).intersectsTimestampset(
        TimestampSet('{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TBoolI(expected_tbooli).intersectsTimestampset(
        TimestampSet('{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False
    assert TBoolI(expected_tbooli).intersectsPeriod(Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TBoolI(expected_tbooli).intersectsPeriod(Period('(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01)')) == False
    assert TBoolI(expected_tbooli).intersectsPeriod(Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False
    assert TBoolI(expected_tbooli).intersectsPeriodset(
        PeriodSet('{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TBoolI(expected_tbooli).intersectsPeriodset(
        PeriodSet('{(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01)}')) == False
    assert TBoolI(expected_tbooli).intersectsPeriodset(
        PeriodSet('{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
print("\nintersectsTimestamp")
t = datetime.strptime('2019-09-09', '%Y-%m-%d')
print(inst.intersectsTimestamp(t))
print(ti.intersectsTimestamp(t))
print(seq.intersectsTimestamp(t))
print(ts.intersectsTimestamp(t))

print("\nintersectsTimestampSet")
tss = TimestampSet('{2019-09-09, 2019-09-10}')
print(inst.intersectsTimestampSet(tss))
print(ti.intersectsTimestampSet(tss))
print(seq.intersectsTimestampSet(tss))
print(ts.intersectsTimestampSet(tss))

print("\nintersectsPeriod")
p = Period('2019-09-09', '2019-09-10', True, True)
print(inst.intersectsPeriod(p))
print(ti.intersectsPeriod(p))
print(seq.intersectsPeriod(p))
print(ts.intersectsPeriod(p))

print("\nintersectsPeriodSet")
ps = PeriodSet('{[2019-09-09,2019-09-10], [2019-09-11,2019-09-12]}')
print(inst.intersectsPeriodSet(ps))
print(ti.intersectsPeriodSet(ps))
print(seq.intersectsPeriodSet(ps))
print(ts.intersectsPeriodSet(ps))

print("\nsrid")
print(inst.srid)
print(ti.srid)
Exemple #14
0
 def period(self):
     """
     Period on which the temporal value is defined.
     """
     return Period(self.startTimestamp, self.endTimestamp, self.lower_inc, self.upper_inc)
Exemple #15
0
def test_tfloats_accessors(cursor, expected_tfloats):
    assert TFloatS(expected_tfloats).duration() == 'SequenceSet'
    #assert TFloatS(expected_tfloats).getValues == [floatrange(10.0, 10.0, upper_inc=True),floatrange(20.0, 30.0, 30.0, upper_inc=True)]
    assert TFloatS(expected_tfloats).startValue == 10.0
    assert TFloatS(expected_tfloats).endValue == 30.0
    assert TFloatS(expected_tfloats).minValue == 10.0
    assert TFloatS(expected_tfloats).maxValue == 30.0
    assert TFloatS(expected_tfloats).valueRange == floatrange(10.0,
                                                              30.0,
                                                              upper_inc=True)
    assert TFloatS(expected_tfloats).getTime == PeriodSet(
        '{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01],[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]}'
    )
    assert TFloatS(expected_tfloats).timespan == timedelta(1)
    assert TFloatS(expected_tfloats).period == Period(
        '[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]')
    assert TFloatS(expected_tfloats).numInstants == 3
    assert TFloatS(expected_tfloats).startInstant == TFloatInst(
        '10.0@2019-09-01 00:00:00+01')
    assert TFloatS(expected_tfloats).endInstant == TFloatInst(
        '30.0@2019-09-03 00:00:00+01')
    assert TFloatS(expected_tfloats).instantN(2) == TFloatInst(
        '20.0@2019-09-02 00:00:00+01')
    assert TFloatS(expected_tfloats).instants == [
        TFloatInst('10.0@2019-09-01 00:00:00+01'),
        TFloatInst('20.0@2019-09-02 00:00:00+01'),
        TFloatInst('30.0@2019-09-03 00:00:00+01')
    ]
    assert TFloatS(expected_tfloats).numTimestamps == 3
    assert TFloatS(expected_tfloats).startTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TFloatS(expected_tfloats).endTimestamp == parse(
        '2019-09-03 00:00:00+01')
    assert TFloatS(expected_tfloats).timestampN(2) == parse(
        '2019-09-02 00:00:00+01')
    assert TFloatS(expected_tfloats).timestamps == [
        parse('2019-09-01 00:00:00+01'),
        parse('2019-09-02 00:00:00+01'),
        parse('2019-09-03 00:00:00+01')
    ]
    assert TFloatS(expected_tfloats).numSequences == 2
    assert TFloatS(expected_tfloats).startSequence == TFloatSeq(
        '[10.0@2019-09-01 00:00:00+01]')
    assert TFloatS(expected_tfloats).endSequence == TFloatSeq(
        '[20.0@2019-09-02 00:00:00+01, 30.0@2019-09-03 00:00:00+01]')
    assert TFloatS(expected_tfloats).sequenceN(2) == TFloatSeq(
        '[20.0@2019-09-02 00:00:00+01, 30.0@2019-09-03 00:00:00+01]')
    assert TFloatS(expected_tfloats).sequences == [
        TFloatSeq('[10.0@2019-09-01 00:00:00+01]'),
        TFloatSeq('[20.0@2019-09-02 00:00:00+01, 30.0@2019-09-03 00:00:00+01]')
    ]
    assert TFloatS(expected_tfloats).intersectsTimestamp(
        parse('2019-09-01 00:00:00+01')) == True
    assert TFloatS(expected_tfloats).intersectsTimestamp(
        parse('2019-09-04 00:00:00+01')) == False
    assert TFloatS(expected_tfloats).intersectsTimestampset(
        TimestampSet(
            '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TFloatS(expected_tfloats).intersectsTimestampset(
        TimestampSet(
            '{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False
    assert TFloatS(expected_tfloats).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TFloatS(expected_tfloats).intersectsPeriod(
        Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False
    assert TFloatS(expected_tfloats).intersectsPeriodset(
        PeriodSet(
            '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TFloatS(expected_tfloats).intersectsPeriodset(
        PeriodSet(
            '{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
Exemple #16
0
 def getTime(self):
     """
     Period set on which the temporal value is defined.
     """
     return PeriodSet([Period(self._time, self._time, True, True)])
Exemple #17
0
 def period(self):
     """
     Period on which the temporal value is defined ignoring the potential
     time gaps.
     """
     return Period(self._time, self._time, True, True)
Exemple #18
0
 def period(self):
     """
     Period on which the temporal value is defined ignoring the potential
     time gaps.
     """
     return Period(self.startTimestamp, self.endTimestamp, True, True)
Exemple #19
0
# UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
# AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
# PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
###############################################################################

from datetime import datetime, timedelta
from dateutil.parser import parse
from mobilitydb.time import TimestampSet, Period, PeriodSet

print("\n# Period")

# Constructors
var = Period('[2019-09-08, 2019-09-10]')
print("Constructor string:", var)
var = Period('[2019-09-08, 2019-09-10)')
print("Constructor string:", var)
var = Period('(2019-09-08, 2019-09-10]')
print("Constructor string:", var)
var = Period('(2019-09-08, 2019-09-10)')
print("Constructor string:", var)
var = Period('2019-09-08', '2019-09-10')
print("Constructor 2 args:", var)
var = Period('2019-09-08', '2019-09-10', False, True)
print("Constructor 4 args:", var)

# Accessor functions
var1 = var.lower
print("lower:", var1)
def test_tfloatinstset_accessors(cursor, expected_tfloatinstset):
    assert TFloatInstSet(expected_tfloatinstset).tempSubtype() == 'InstantSet'
    assert TFloatInstSet(expected_tfloatinstset).getValues == [
        floatrange(10.0, 10.0, upper_inc=True),
        floatrange(20.0, 20.0, upper_inc=True),
        floatrange(30.0, 30.0, upper_inc=True)
    ]
    assert TFloatInstSet(expected_tfloatinstset).startValue == 10.0
    assert TFloatInstSet(expected_tfloatinstset).endValue == 30.0
    assert TFloatInstSet(expected_tfloatinstset).minValue == 10.0
    assert TFloatInstSet(expected_tfloatinstset).maxValue == 30.0
    assert TFloatInstSet(expected_tfloatinstset).valueRange == floatrange(
        10.0, 30.0, upper_inc=True)
    assert TFloatInstSet(expected_tfloatinstset).getTime == \
           PeriodSet(
               '{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01], [2019-09-02 00:00:00+01, 2019-09-02 00:00:00+01], '
               '[2019-09-03 00:00:00+01, 2019-09-03 00:00:00+01]}')
    assert TFloatInstSet(expected_tfloatinstset).duration == timedelta(0)
    assert TFloatInstSet(expected_tfloatinstset).timespan == timedelta(2)
    assert TFloatInstSet(expected_tfloatinstset).period == Period(
        '[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]')
    assert TFloatInstSet(expected_tfloatinstset).numInstants == 3
    assert TFloatInstSet(expected_tfloatinstset).startInstant == TFloatInst(
        '10.0@2019-09-01 00:00:00+01')
    assert TFloatInstSet(expected_tfloatinstset).endInstant == TFloatInst(
        '30.0@2019-09-03 00:00:00+01')
    assert TFloatInstSet(expected_tfloatinstset).instantN(2) == TFloatInst(
        '20.0@2019-09-02 00:00:00+01')
    assert TFloatInstSet(expected_tfloatinstset).instants == [
        TFloatInst('10.0@2019-09-01 00:00:00+01'),
        TFloatInst('20.0@2019-09-02 00:00:00+01'),
        TFloatInst('30.0@2019-09-03 00:00:00+01')
    ]
    assert TFloatInstSet(expected_tfloatinstset).numTimestamps == 3
    assert TFloatInstSet(expected_tfloatinstset).startTimestamp == parse(
        '2019-09-01 00:00:00+01')
    assert TFloatInstSet(expected_tfloatinstset).endTimestamp == parse(
        '2019-09-03 00:00:00+01')
    assert TFloatInstSet(expected_tfloatinstset).timestampN(2) == parse(
        '2019-09-02 00:00:00+01')
    assert TFloatInstSet(expected_tfloatinstset).timestamps == [
        parse('2019-09-01 00:00:00+01'),
        parse('2019-09-02 00:00:00+01'),
        parse('2019-09-03 00:00:00+01')
    ]
    assert TFloatInstSet(expected_tfloatinstset).intersectsTimestamp(
        parse('2019-09-01 00:00:00+01')) == True
    assert TFloatInstSet(expected_tfloatinstset).intersectsTimestamp(
        parse('2019-09-04 00:00:00+01')) == False
    assert TFloatInstSet(expected_tfloatinstset).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TFloatInstSet(expected_tfloatinstset).intersectsTimestampSet(
        TimestampSet(
            '{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False
    assert TFloatInstSet(expected_tfloatinstset).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TFloatInstSet(expected_tfloatinstset).intersectsPeriod(
        Period('(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01)')) == False
    assert TFloatInstSet(expected_tfloatinstset).intersectsPeriod(
        Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False
    assert TFloatInstSet(expected_tfloatinstset).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TFloatInstSet(expected_tfloatinstset).intersectsPeriodSet(
        PeriodSet(
            '{(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01)}')) == False
    assert TFloatInstSet(expected_tfloatinstset).intersectsPeriodSet(
        PeriodSet(
            '{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False