async def test_tgeogpointseq_constructor(connection, expected_tgeogpointseq): if isinstance(expected_tgeogpointseq, tuple): params = TGeogPointSeq(*expected_tgeogpointseq) else: params = TGeogPointSeq(expected_tgeogpointseq) await connection.execute('INSERT INTO tbl_tgeogpointseq (temp) VALUES ($1)', params) result = await connection.fetchval('SELECT temp FROM tbl_tgeogpointseq WHERE temp=$1', params) if isinstance(expected_tgeogpointseq, tuple): assert result == TGeogPointSeq(*expected_tgeogpointseq) else: assert result == TGeogPointSeq(expected_tgeogpointseq)
def test_tgeogpointseq_constructor(cursor, expected_tgeogpointseq): if isinstance(expected_tgeogpointseq, tuple): params = [TGeogPointSeq(*expected_tgeogpointseq)] else: params = [TGeogPointSeq(expected_tgeogpointseq)] cursor.execute('INSERT INTO tbl_tgeogpointseq (temp) VALUES (%s)', params) cursor.execute('SELECT temp FROM tbl_tgeogpointseq WHERE temp=%s', params) result = cursor.fetchone()[0] if isinstance(expected_tgeogpointseq, tuple): assert result == TGeogPointSeq(*expected_tgeogpointseq) else: assert result == TGeogPointSeq(expected_tgeogpointseq)
def test_tgeogpoints_accessors(cursor, expected_tgeogpoints): assert TGeogPointS(expected_tgeogpoints).srid == 4326 assert TGeogPointS(expected_tgeogpoints).duration() == 'SequenceSet' assert TGeogPointS(expected_tgeogpoints).getValues == \ GeometryCollection([Point(10.0, 10.0), LineString([Point(20.0, 20.0), Point(30.0, 30.0)])]) assert TGeogPointS(expected_tgeogpoints).startValue == Point(10.0, 10.0) assert TGeogPointS(expected_tgeogpoints).endValue == Point(30.0, 30.0) # assert TGeogPointS(expected_tgeogpoints).valueRange == geompointrange(Point(10.0, 10.0), Point(30.0, 30.0), upper_inc=True) assert TGeogPointS(expected_tgeogpoints).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 TGeogPointS(expected_tgeogpoints).timespan == timedelta(1) assert TGeogPointS(expected_tgeogpoints).period == Period( '[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]') assert TGeogPointS(expected_tgeogpoints).numInstants == 3 assert TGeogPointS(expected_tgeogpoints).startInstant == TGeogPointInst( 'Point(10.0 10.0)@2019-09-01 00:00:00+01') assert TGeogPointS(expected_tgeogpoints).endInstant == TGeogPointInst( 'Point(30.0 30.0)@2019-09-03 00:00:00+01') assert TGeogPointS(expected_tgeogpoints).instantN(2) == TGeogPointInst( 'Point(20.0 20.0)@2019-09-02 00:00:00+01') assert TGeogPointS(expected_tgeogpoints).instants == [ TGeogPointInst('Point(10.0 10.0)@2019-09-01 00:00:00+01'), TGeogPointInst('Point(20.0 20.0)@2019-09-02 00:00:00+01'), TGeogPointInst('Point(30.0 30.0)@2019-09-03 00:00:00+01') ] assert TGeogPointS(expected_tgeogpoints).numTimestamps == 3 assert TGeogPointS(expected_tgeogpoints).startTimestamp == parse( '2019-09-01 00:00:00+01') assert TGeogPointS(expected_tgeogpoints).endTimestamp == parse( '2019-09-03 00:00:00+01') assert TGeogPointS(expected_tgeogpoints).timestampN(2) == parse( '2019-09-02 00:00:00+01') assert TGeogPointS(expected_tgeogpoints).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 TGeogPointS(expected_tgeogpoints).numSequences == 2 assert TGeogPointS(expected_tgeogpoints).startSequence == TGeogPointSeq( '[Point(10.0 10.0)@2019-09-01 00:00:00+01]') assert TGeogPointS(expected_tgeogpoints).endSequence == TGeogPointSeq( '[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 TGeogPointS(expected_tgeogpoints).sequenceN(2) == TGeogPointSeq( '[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 TGeogPointS(expected_tgeogpoints).sequences == [ TGeogPointSeq('[Point(10.0 10.0)@2019-09-01 00:00:00+01]'), TGeogPointSeq( '[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 TGeogPointS(expected_tgeogpoints).intersectsTimestamp( parse('2019-09-01 00:00:00+01')) == True assert TGeogPointS(expected_tgeogpoints).intersectsTimestamp( parse('2019-09-04 00:00:00+01')) == False assert TGeogPointS(expected_tgeogpoints).intersectsTimestampset( TimestampSet( '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True assert TGeogPointS(expected_tgeogpoints).intersectsTimestampset( TimestampSet( '{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False assert TGeogPointS(expected_tgeogpoints).intersectsPeriod( Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True assert TGeogPointS(expected_tgeogpoints).intersectsPeriod( Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False assert TGeogPointS(expected_tgeogpoints).intersectsPeriodset( PeriodSet( '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True assert TGeogPointS(expected_tgeogpoints).intersectsPeriodset( PeriodSet( '{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
def test_tgeogpointseq_accessors(cursor, expected_tgeogpointseq): assert TGeogPointSeq(expected_tgeogpointseq).srid == 4326 assert TGeogPointSeq(expected_tgeogpointseq).duration() == 'Sequence' assert TGeogPointSeq(expected_tgeogpointseq).getValues == LineString( [Point(10.0, 10.0), Point(20.0, 20.0), Point(10.0, 10.0)]) assert TGeogPointSeq(expected_tgeogpointseq).startValue == Point( 10.0, 10.0) assert TGeogPointSeq(expected_tgeogpointseq).endValue == Point(10.0, 10.0) assert TGeogPointSeq(expected_tgeogpointseq).getTime == PeriodSet( '{[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]}') assert TGeogPointSeq(expected_tgeogpointseq).timespan == timedelta(2) assert TGeogPointSeq(expected_tgeogpointseq).period == Period( '[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]') assert TGeogPointSeq(expected_tgeogpointseq).numInstants == 3 assert TGeogPointSeq( expected_tgeogpointseq).startInstant == TGeogPointInst( 'Point(10.0 10.0)@2019-09-01 00:00:00+01') assert TGeogPointSeq(expected_tgeogpointseq).endInstant == TGeogPointInst( 'Point(10.0 10.0)@2019-09-03 00:00:00+01') assert TGeogPointSeq(expected_tgeogpointseq).instantN(2) == TGeogPointInst( 'Point(20.0 20.0)@2019-09-02 00:00:00+01') assert TGeogPointSeq(expected_tgeogpointseq).instants == \ [TGeogPointInst('Point(10.0 10.0)@2019-09-01 00:00:00+01'), TGeogPointInst('Point(20.0 20.0)@2019-09-02 00:00:00+01'), TGeogPointInst('Point(10.0 10.0)@2019-09-03 00:00:00+01')] assert TGeogPointSeq(expected_tgeogpointseq).numTimestamps == 3 assert TGeogPointSeq(expected_tgeogpointseq).startTimestamp == parse( '2019-09-01 00:00:00+01') assert TGeogPointSeq(expected_tgeogpointseq).endTimestamp == parse( '2019-09-03 00:00:00+01') assert TGeogPointSeq(expected_tgeogpointseq).timestampN(2) == parse( '2019-09-02 00:00:00+01') assert TGeogPointSeq(expected_tgeogpointseq).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 TGeogPointSeq(expected_tgeogpointseq).intersectsTimestamp( parse('2019-09-01 00:00:00+01')) == True assert TGeogPointSeq(expected_tgeogpointseq).intersectsTimestamp( parse('2019-09-04 00:00:00+01')) == False assert TGeogPointSeq(expected_tgeogpointseq).intersectsTimestampset( TimestampSet( '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True assert TGeogPointSeq(expected_tgeogpointseq).intersectsTimestampset( TimestampSet( '{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False assert TGeogPointSeq(expected_tgeogpointseq).intersectsPeriod( Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True assert TGeogPointSeq(expected_tgeogpointseq).intersectsPeriod( Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False assert TGeogPointSeq(expected_tgeogpointseq).intersectsPeriodset( PeriodSet( '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True assert TGeogPointSeq(expected_tgeogpointseq).intersectsPeriodset( PeriodSet( '{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
'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), [ TGeogPointSeq('[Point(10.0 10.0)@2019-09-01 00:00:00+01]'), TGeogPointSeq( '[Point(20.0 20.0)@2019-09-02 00:00:00+01, Point(10.0 10.0)@2019-09-03 00:00:00+01]' ) ], ([ TGeogPointSeq('[Point(10.0 10.0)@2019-09-01 00:00:00+01]'), TGeogPointSeq( '[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'), ([ TGeogPointSeq( 'Interp=Stepwise;[Point(10.0 10.0)@2019-09-01 00:00:00+01]'), TGeogPointSeq( '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]'