Skip to content

Commit

Permalink
Add TPoint Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Diviloper committed May 6, 2024
1 parent e77b7e6 commit 7d9d26f
Show file tree
Hide file tree
Showing 2 changed files with 336 additions and 33 deletions.
159 changes: 154 additions & 5 deletions tests/main/tgeogpoint_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import pytest
import shapely.geometry
from pymeos_cffi import MeosInvalidArgValueError
from pymeos_cffi import MeosInvalidArgValueError, MeosException
from shapely import Point, LineString, set_srid

from pymeos import (
Expand Down Expand Up @@ -297,6 +297,158 @@ def test_instant_list_sequence_constructor(
assert str(tps2) == expected
assert tps2.interpolation() == interpolation

@pytest.mark.parametrize(
"params, result",
[
(
(
[
TGeogPointInst("POINT(1 1)@2000-01-01"),
TGeogPointInst("POINT(5 5)@2000-01-02"),
TGeogPointInst("POINT(6 6)@2000-01-05"),
],
TInterpolation.STEPWISE,
None,
),
TGeogPointSeqSet(
"Interp=Step;{[POINT(1 1)@2000-01-01, POINT(5 5)@2000-01-02, POINT(6 6)@2000-01-05]}"
),
),
(
(
[
TGeogPointInst("POINT(1 1)@2000-01-01"),
TGeogPointInst("POINT(5 5)@2000-01-02"),
TGeogPointInst("POINT(6 6)@2000-01-05"),
],
TInterpolation.STEPWISE,
None,
200000.0,
),
TGeogPointSeqSet(
"Interp=Step;{[POINT(1 1)@2000-01-01], [POINT(5 5)@2000-01-02, POINT(6 6)@2000-01-05]}"
),
),
(
(
[
TGeogPointInst("POINT(1 1)@2000-01-01"),
TGeogPointInst("POINT(5 5)@2000-01-02"),
TGeogPointInst("POINT(6 6)@2000-01-05"),
],
TInterpolation.STEPWISE,
timedelta(days=2),
),
TGeogPointSeqSet(
"Interp=Step;{[POINT(1 1)@2000-01-01, POINT(5 5)@2000-01-02], [POINT(6 6)@2000-01-05]}"
),
),
(
(
[
TGeogPointInst("POINT(1 1)@2000-01-01"),
TGeogPointInst("POINT(5 5)@2000-01-02"),
TGeogPointInst("POINT(6 6)@2000-01-05"),
],
TInterpolation.STEPWISE,
timedelta(days=2),
200000.0,
),
TGeogPointSeqSet(
"Interp=Step;{[POINT(1 1)@2000-01-01], [POINT(5 5)@2000-01-02], [POINT(6 6)@2000-01-05]}"
),
),
(
(
[
TGeogPointInst("POINT(1 1)@2000-01-01"),
TGeogPointInst("POINT(5 5)@2000-01-02"),
TGeogPointInst("POINT(6 6)@2000-01-05"),
],
TInterpolation.LINEAR,
None,
),
TGeogPointSeqSet(
"{[POINT(1 1)@2000-01-01, POINT(5 5)@2000-01-02, POINT(6 6)@2000-01-05]}"
),
),
(
(
[
TGeogPointInst("POINT(1 1)@2000-01-01"),
TGeogPointInst("POINT(5 5)@2000-01-02"),
TGeogPointInst("POINT(6 6)@2000-01-05"),
],
TInterpolation.LINEAR,
None,
200000.0,
),
TGeogPointSeqSet(
"{[POINT(1 1)@2000-01-01], [POINT(5 5)@2000-01-02, POINT(6 6)@2000-01-05]}"
),
),
(
(
[
TGeogPointInst("POINT(1 1)@2000-01-01"),
TGeogPointInst("POINT(5 5)@2000-01-02"),
TGeogPointInst("POINT(6 6)@2000-01-05"),
],
TInterpolation.LINEAR,
timedelta(days=2),
),
TGeogPointSeqSet(
"{[POINT(1 1)@2000-01-01, POINT(5 5)@2000-01-02], [POINT(6 6)@2000-01-05]}"
),
),
(
(
[
TGeogPointInst("POINT(1 1)@2000-01-01"),
TGeogPointInst("POINT(5 5)@2000-01-02"),
TGeogPointInst("POINT(6 6)@2000-01-05"),
],
TInterpolation.LINEAR,
timedelta(days=2),
200000.0,
),
TGeogPointSeqSet(
"{[POINT(1 1)@2000-01-01], [POINT(5 5)@2000-01-02], [POINT(6 6)@2000-01-05]}"
),
),
],
ids=[
"No Gaps Stepwise",
"Value Gaps Stepwise",
"Time Gaps Stepwise",
"Value and Time Gaps Stepwise",
"No Gaps Linear",
"Value Gaps Linear",
"Time Gaps Linear",
"Value and Time Gaps Linear",
],
)
def test_gaps_constructor(self, params, result):
assert TGeogPointSeqSet.from_instants_with_gaps(*params) == result

@pytest.mark.parametrize(
"params",
[
{"interpolation": TInterpolation.DISCRETE},
],
ids=[
"Discrete Interpolation",
],
)
def test_gaps_constructor_with_invalid_parameters_raises(self, params):
instants = [
TGeogPointInst(point="POINT(1 1)", timestamp="2000-01-01"),
TGeogPointInst(point="POINT(5 5)", timestamp="2000-01-02"),
TGeogPointInst(point="POINT(6 6)", timestamp="2000-01-03"),
]
with pytest.raises(MeosException):
TGeogPointSeqSet.from_instants_with_gaps(instants, **params)

@pytest.mark.parametrize(
"temporal",
[tpi, tpds, tps, tpss, tpi3d, tpds3d, tps3d, tpss3d],
Expand Down Expand Up @@ -1812,10 +1964,7 @@ def test_round(self, temporal, expected):
[
(
TGeogPointInst("Point(42.84979 42.38153)@2019-09-01"),
TGeogPointInst(
"SRID=8426;"
"Point(42.84979 42.38153)@2019-09-01"
),
TGeogPointInst("SRID=8426;" "Point(42.84979 42.38153)@2019-09-01"),
),
(
TGeogPointSeq(
Expand Down
Loading

0 comments on commit 7d9d26f

Please sign in to comment.