async def test_tgeompointseq_constructor(connection, expected_tgeompointseq): if isinstance(expected_tgeompointseq, tuple): params = TGeomPointSeq(*expected_tgeompointseq) else: params = TGeomPointSeq(expected_tgeompointseq) await connection.execute('INSERT INTO tbl_tgeompointseq (temp) VALUES ($1)', params) result = await connection.fetchval('SELECT temp FROM tbl_tgeompointseq WHERE temp=$1', params) if isinstance(expected_tgeompointseq, tuple): assert result == TGeomPointSeq(*expected_tgeompointseq) else: assert result == TGeomPointSeq(expected_tgeompointseq)
def test_tgeompointseq_constructor(cursor, expected_tgeompointseq): if isinstance(expected_tgeompointseq, tuple): params = [TGeomPointSeq(*expected_tgeompointseq)] else: params = [TGeomPointSeq(expected_tgeompointseq)] cursor.execute('INSERT INTO tbl_tgeompointseq (temp) VALUES (%s)', params) cursor.execute('SELECT temp FROM tbl_tgeompointseq WHERE temp=%s', params) result = cursor.fetchone()[0] if isinstance(expected_tgeompointseq, tuple): assert result == TGeomPointSeq(*expected_tgeompointseq) else: assert result == TGeomPointSeq(expected_tgeompointseq)
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 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
(['[Point(10.0 10.0)@2019-09-01 00:00:00+01]', '[Point(20.0 20.0)@2019-09-02 00:00:00+01, Point(10.0 10.0)@2019-09-03 00:00:00+01]'], 'Linear', 4326), (['SRID=4326;[Point(10.0 10.0)@2019-09-01 00:00:00+01]', 'SRID=4326;[Point(20.0 20.0)@2019-09-02 00:00:00+01, Point(10.0 10.0)@2019-09-03 00:00:00+01]'], 'Linear'), (['SRID=4326;[Point(10.0 10.0)@2019-09-01 00:00:00+01]', 'SRID=4326;[Point(20.0 20.0)@2019-09-02 00:00:00+01, Point(10.0 10.0)@2019-09-03 00:00:00+01]'], 'Linear', 4326), (['Interp=Stepwise;[Point(10.0 10.0)@2019-09-01 00:00:00+01]', 'Interp=Stepwise;[Point(20.0 20.0)@2019-09-02 00:00:00+01, Point(10.0 10.0)@2019-09-03 00:00:00+01]'], 'Stepwise'), (['SRID=4326;Interp=Stepwise;[Point(10.0 10.0)@2019-09-01 00:00:00+01]', 'SRID=4326;Interp=Stepwise;[Point(20.0 20.0)@2019-09-02 00:00:00+01, Point(10.0 10.0)@2019-09-03 00:00:00+01]'], 'Stepwise', 4326), (['Interp=Stepwise;[Point(10.0 10.0)@2019-09-01 00:00:00+01]', 'Interp=Stepwise;[Point(20.0 20.0)@2019-09-02 00:00:00+01, Point(10.0 10.0)@2019-09-03 00:00:00+01]'], 'Stepwise', 4326), [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(10.0 10.0)@2019-09-03 00:00:00+01]')], ([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(10.0 10.0)@2019-09-03 00:00:00+01]')], 'Linear'), ([TGeomPointSeq('Interp=Stepwise;[Point(10.0 10.0)@2019-09-01 00:00:00+01]'), TGeomPointSeq( 'Interp=Stepwise;[Point(20.0 20.0)@2019-09-02 00:00:00+01, Point(10.0 10.0)@2019-09-03 00:00:00+01]')], 'Stepwise'), ]) def test_tgeompointseqset_constructor(cursor, expected_tgeompointseqset): if isinstance(expected_tgeompointseqset, tuple): params = [TGeomPointSeqSet(*expected_tgeompointseqset)] else: params = [TGeomPointSeqSet(expected_tgeompointseqset)] cursor.execute('INSERT INTO tbl_tgeompointseqset (temp) VALUES (%s)', params) cursor.execute('SELECT temp FROM tbl_tgeompointseqset WHERE temp=%s', params)