コード例 #1
0
def test_different_geom_constructors(expected_srid, actual):
    assert actual.duration == TemporalDuration.InstantSet
    assert actual.duration.name == 'InstantSet'
    assert len(actual.instants) == 2
    assert actual.startInstant == TGeomPointInst(
        GeomPoint(24, 32, expected_srid), unix_dt(2019, 9, 10))
    assert actual.endInstant == TGeomPointInst(
        GeomPoint(20, 30, expected_srid), unix_dt(2020, 9, 10))
    assert actual.srid == expected_srid
    assert actual.startValue.srid == expected_srid
コード例 #2
0
def test_different_geom_constructors(expected_srid, actual):
    assert actual.duration == TemporalDuration.Sequence
    assert actual.duration.name == 'Sequence'
    assert len(actual.instants) == 2
    assert actual.startInstant == TGeomPointInst(GeomPoint(24, 32, expected_srid), unix_dt(2019, 9, 10))
    assert actual.endInstant == TGeomPointInst(GeomPoint(20, 30, expected_srid), unix_dt(2020, 9, 10))
    assert actual.lower_inc == True
    assert actual.upper_inc == False
    assert actual.srid == expected_srid
    assert actual.startInstant.srid == expected_srid
    assert actual.startValue.srid == expected_srid
コード例 #3
0
def test_constructor_different_base_types():
    rb = RangeBool(False, True)
    ri = RangeInt(10, 20)
    rf = RangeFloat(1.25, 6.25)
    rt = RangeText("example", "testing")
    rg = RangeGeom(GeomPoint(10.0, 15.0), GeomPoint(20, 24))

    assert (rb.lower, rb.upper) == (False, True)
    assert (ri.lower, ri.upper) == (10, 20)
    assert (rf.lower, rf.upper) == (1.25, 6.25)
    assert (rt.lower, rt.upper) == ("example", "testing")
    assert (rg.lower.toWKT(), rg.upper.toWKT()) == ("POINT (10 15)",
                                                    "POINT (20 24)")
コード例 #4
0
def test_different_geom_constructors(expected_srid, actual):
    assert actual.duration == TemporalDuration.SequenceSet
    assert actual.duration.name == 'SequenceSet'

    assert actual.srid == expected_srid
    assert actual.startSequence.srid == expected_srid
    assert actual.startInstant.srid == expected_srid
    assert actual.startValue.srid == expected_srid

    assert len(actual.sequences) == 2
    assert actual.startSequence == get_sample_geom_tseq_1(expected_srid)
    assert actual.endSequence == get_sample_geom_tseq_2(expected_srid)

    assert len(actual.instants) == 4
    assert actual.startInstant == TGeomPointInst(
        GeomPoint(10, 12, expected_srid), unix_dt(2011, 1, 1))
    assert actual.endInstant == TGeomPointInst(
        GeomPoint(30, 32, expected_srid), unix_dt(2011, 1, 4))
コード例 #5
0
def test_different_geom_constructors(expected_srid, actual):
    assert actual.duration == TemporalDuration.Instant
    assert actual.duration.name == 'Instant'
    assert actual.getValue == GeomPoint(20, 30, expected_srid)
    assert actual.getTimestamp == unix_dt(2011, 1, 1)
    srid_prefix = 'SRID={};'.format(
        expected_srid) if expected_srid != 0 else ''
    assert str(
        actual) == srid_prefix + 'POINT (20 30)@2011-01-01T00:00:00+0000'
    assert actual.srid == expected_srid
コード例 #6
0
def test_constructor_different_base_types():
    tb = TBoolInst(True, unix_dt(2011, 1, 1))
    ti = TIntInst(10, unix_dt(2011, 1, 1))
    tf = TFloatInst(1.25, unix_dt(2011, 1, 1))
    tt = TTextInst("testing", unix_dt(2011, 1, 1))
    tg = TGeomPointInst(GeomPoint(10.0, 15.0), unix_dt(2011, 1, 1))

    assert (tb.getValue, ti.getTimestamp) == (True, unix_dt(2011, 1, 1))
    assert (ti.getValue, ti.getTimestamp) == (10, unix_dt(2011, 1, 1))
    assert (tf.getValue, ti.getTimestamp) == (1.25, unix_dt(2011, 1, 1))
    assert (tt.getValue, tt.getTimestamp) == ("testing", unix_dt(2011, 1, 1))
    assert (tg.getValue.toWKT(), tg.getTimestamp) == ("POINT (10 15)",
                                                      unix_dt(2011, 1, 1))
コード例 #7
0
    }),
    TIntInstSet({"10@2020-09-10 01:00:00+01", "20@2019-09-10 01:00:00+01"}),
    TIntInstSet("{10@2020-09-10 01:00:00+01, 20@2019-09-10 01:00:00+01}"),
])
def test_different_constructors(actual):
    assert actual.duration == TemporalDuration.InstantSet
    assert actual.duration.name == 'InstantSet'
    assert len(actual.instants) == 2
    assert actual.startInstant == TIntInst(20, unix_dt(2019, 9, 10))
    assert actual.endInstant == TIntInst(10, unix_dt(2020, 9, 10))


@pytest.mark.parametrize("expected_srid, actual", [
    (0,
     TGeomPointInstSet({
         TGeomPointInst(GeomPoint(20, 30), unix_dt(2020, 9, 10)),
         TGeomPointInst(GeomPoint(24, 32), unix_dt(2019, 9, 10))
     })),
    (4326,
     TGeomPointInstSet(
         {
             TGeomPointInst(GeomPoint(20, 30), unix_dt(2020, 9, 10)),
             TGeomPointInst(GeomPoint(24, 32), unix_dt(2019, 9, 10))
         }, 4326)),
    (4326,
     TGeomPointInstSet({
         TGeomPointInst(GeomPoint(20, 30, 4326), unix_dt(2020, 9, 10)),
         TGeomPointInst(GeomPoint(24, 32, 4326), unix_dt(2019, 9, 10))
     })),
    (4326,
     TGeomPointInstSet(
コード例 #8
0
    assert actual.interpolation == Interpolation.Linear
    assert actual.interpolation.name == 'Linear'

    assert len(actual.instants) == 2
    assert actual.startInstant == TFloatInst(20, unix_dt(2019, 9, 10))
    assert actual.endInstant == TFloatInst(10, unix_dt(2020, 9, 10))

    assert actual.lower_inc == False
    assert actual.upper_inc == True

    assert str(actual) == "(20@2019-09-10T00:00:00+0000, 10@2020-09-10T00:00:00+0000]"
    assert repr(actual) == "(20@2019-09-10T00:00:00+0000, 10@2020-09-10T00:00:00+0000]"


@pytest.mark.parametrize("expected_srid, actual", [
    (0,    TGeomPointSeq({TGeomPointInst(GeomPoint(20, 30), unix_dt(2020, 9, 10)), TGeomPointInst(GeomPoint(24, 32), unix_dt(2019, 9, 10))}, True, False)),
    (4326, TGeomPointSeq({TGeomPointInst(GeomPoint(20, 30), unix_dt(2020, 9, 10)), TGeomPointInst(GeomPoint(24, 32), unix_dt(2019, 9, 10))}, True, False, 4326)),
    (4326, TGeomPointSeq({TGeomPointInst(GeomPoint(20, 30, 4326), unix_dt(2020, 9, 10)), TGeomPointInst(GeomPoint(24, 32, 4326), unix_dt(2019, 9, 10))}, True, False)),
    (4326, TGeomPointSeq({TGeomPointInst(GeomPoint(20, 30, 4326), unix_dt(2020, 9, 10)), TGeomPointInst(GeomPoint(24, 32, 4326), unix_dt(2019, 9, 10))}, True, False, 0)),
    (4326, TGeomPointSeq({TGeomPointInst(GeomPoint(20, 30, 4326), unix_dt(2020, 9, 10)), TGeomPointInst(GeomPoint(24, 32, 4326), unix_dt(2019, 9, 10))}, True, False, 4326)),

    (0,    TGeomPointSeq({"POINT (20 30)@2020-09-10 01:00:00+01", "POINT (24 32)@2019-09-10 01:00:00+01"}, True, False)),
    (4326, TGeomPointSeq({"POINT (20 30)@2020-09-10 01:00:00+01", "POINT (24 32)@2019-09-10 01:00:00+01"}, True, False, 4326)),
    (4326, TGeomPointSeq({"SRID=4326;POINT (20 30)@2020-09-10 01:00:00+01", "SRID=4326;POINT (24 32)@2019-09-10 01:00:00+01"}, True, False)),
    (4326, TGeomPointSeq({"SRID=4326;POINT (20 30)@2020-09-10 01:00:00+01", "SRID=4326;POINT (24 32)@2019-09-10 01:00:00+01"}, True, False, 0)),
    (4326, TGeomPointSeq({"SRID=4326;POINT (20 30)@2020-09-10 01:00:00+01", "SRID=4326;POINT (24 32)@2019-09-10 01:00:00+01"}, True, False, 4326)),

    (0,    TGeomPointSeq("[POINT (20 30)@2020-09-10 01:00:00+01, POINT (24 32)@2019-09-10 01:00:00+01)")),
    (4326, TGeomPointSeq("[POINT (20 30)@2020-09-10 01:00:00+01, POINT (24 32)@2019-09-10 01:00:00+01)", 4326)),
    (4326, TGeomPointSeq("[SRID=4326;POINT (20 30)@2020-09-10 01:00:00+01, SRID=4326;POINT (24 32)@2019-09-10 01:00:00+01)")),
    (4326, TGeomPointSeq("[SRID=4326;POINT (20 30)@2020-09-10 01:00:00+01, SRID=4326;POINT (24 32)@2019-09-10 01:00:00+01)", 0)),
コード例 #9
0
def test_str():
    tg = TGeomPointInst(GeomPoint(10.0, 15.0), unix_dt(2011, 1, 1))
    assert str(tg) == "POINT (10 15)@2011-01-01T00:00:00+0000"
    assert repr(tg) == "POINT (10 15)@2011-01-01T00:00:00+0000"
コード例 #10
0
@pytest.mark.parametrize("actual", [
    TIntInst(10, unix_dt(2011, 1, 1)),
    TIntInst((10, unix_dt(2011, 1, 1))),
    TIntInst("10", "2011-01-01"),
    TIntInst(("10", "2011-01-01")),
    TIntInst("10@2011-01-01"),
])
def test_different_int_constructors(actual):
    assert actual.duration == TemporalDuration.Instant
    assert actual.duration.name == 'Instant'
    assert actual.getValue == 10
    assert actual.getTimestamp == unix_dt(2011, 1, 1)


@pytest.mark.parametrize("expected_srid, actual", [
    (0, TGeomPointInst(GeomPoint(20, 30), unix_dt(2011, 1, 1))),
    (4326, TGeomPointInst(GeomPoint(20, 30), unix_dt(2011, 1, 1), 4326)),
    (4326, TGeomPointInst(GeomPoint(20, 30, 4326), unix_dt(2011, 1, 1))),
    (4326, TGeomPointInst(GeomPoint(20, 30, 4326), unix_dt(2011, 1, 1), 4326)),
    (0, TGeomPointInst((GeomPoint(20, 30), unix_dt(2011, 1, 1)))),
    (4326, TGeomPointInst((GeomPoint(20, 30), unix_dt(2011, 1, 1)), 4326)),
    (4326, TGeomPointInst((GeomPoint(20, 30, 4326), unix_dt(2011, 1, 1)))),
    (4326, TGeomPointInst(
        (GeomPoint(20, 30, 4326), unix_dt(2011, 1, 1)), 4326)),
    (0, TGeomPointInst("POINT (20 30)", "2011-01-01")),
    (4326, TGeomPointInst("POINT (20 30)", "2011-01-01", 4326)),
    (4326, TGeomPointInst("SRID=4326;POINT (20 30)", "2011-01-01")),
    (4326, TGeomPointInst("SRID=4326;POINT (20 30)", "2011-01-01", 4326)),
    (0, TGeomPointInst(("POINT (20 30)", "2011-01-01"))),
    (4326, TGeomPointInst(("POINT (20 30)", "2011-01-01"), 4326)),
    (4326, TGeomPointInst(("SRID=4326;POINT (20 30)", "2011-01-01"))),
コード例 #11
0
def test_str():
    tg = RangeGeom(GeomPoint(10.0, 15.0), GeomPoint(20, 24))
    assert str(tg) == "[POINT (10 15), POINT (20 24))"
コード例 #12
0
def get_sample_geom_tseq_2(srid=None):
    instant_1 = TGeomPointInst(GeomPoint(20, 22), unix_dt(2011, 1, 3))
    instant_2 = TGeomPointInst(GeomPoint(30, 32), unix_dt(2011, 1, 4))
    s = {instant_1, instant_2}
    return TGeomPointSeq(s) if srid is None else TGeomPointSeq(
        s, True, False, srid)
コード例 #13
0
def get_sample_geom_tseq_1(srid=None):
    instant_1 = TGeomPointInst(GeomPoint(10, 12), unix_dt(2011, 1, 1))
    instant_2 = TGeomPointInst(GeomPoint(40, 42), unix_dt(2011, 1, 2))
    s = {instant_1, instant_2}
    return TGeomPointSeq(s) if srid is None else TGeomPointSeq(
        s, True, False, srid)
コード例 #14
0
 def write_instant_value(value):
     return GeomPoint(value.wkt)