Skip to content

Commit 7d9d26f

Browse files
committed
Add TPoint Tests
1 parent e77b7e6 commit 7d9d26f

File tree

2 files changed

+336
-33
lines changed

2 files changed

+336
-33
lines changed

tests/main/tgeogpoint_test.py

Lines changed: 154 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
import pytest
77
import shapely.geometry
8-
from pymeos_cffi import MeosInvalidArgValueError
8+
from pymeos_cffi import MeosInvalidArgValueError, MeosException
99
from shapely import Point, LineString, set_srid
1010

1111
from pymeos import (
@@ -297,6 +297,158 @@ def test_instant_list_sequence_constructor(
297297
assert str(tps2) == expected
298298
assert tps2.interpolation() == interpolation
299299

300+
@pytest.mark.parametrize(
301+
"params, result",
302+
[
303+
(
304+
(
305+
[
306+
TGeogPointInst("POINT(1 1)@2000-01-01"),
307+
TGeogPointInst("POINT(5 5)@2000-01-02"),
308+
TGeogPointInst("POINT(6 6)@2000-01-05"),
309+
],
310+
TInterpolation.STEPWISE,
311+
None,
312+
),
313+
TGeogPointSeqSet(
314+
"Interp=Step;{[POINT(1 1)@2000-01-01, POINT(5 5)@2000-01-02, POINT(6 6)@2000-01-05]}"
315+
),
316+
),
317+
(
318+
(
319+
[
320+
TGeogPointInst("POINT(1 1)@2000-01-01"),
321+
TGeogPointInst("POINT(5 5)@2000-01-02"),
322+
TGeogPointInst("POINT(6 6)@2000-01-05"),
323+
],
324+
TInterpolation.STEPWISE,
325+
None,
326+
200000.0,
327+
),
328+
TGeogPointSeqSet(
329+
"Interp=Step;{[POINT(1 1)@2000-01-01], [POINT(5 5)@2000-01-02, POINT(6 6)@2000-01-05]}"
330+
),
331+
),
332+
(
333+
(
334+
[
335+
TGeogPointInst("POINT(1 1)@2000-01-01"),
336+
TGeogPointInst("POINT(5 5)@2000-01-02"),
337+
TGeogPointInst("POINT(6 6)@2000-01-05"),
338+
],
339+
TInterpolation.STEPWISE,
340+
timedelta(days=2),
341+
),
342+
TGeogPointSeqSet(
343+
"Interp=Step;{[POINT(1 1)@2000-01-01, POINT(5 5)@2000-01-02], [POINT(6 6)@2000-01-05]}"
344+
),
345+
),
346+
(
347+
(
348+
[
349+
TGeogPointInst("POINT(1 1)@2000-01-01"),
350+
TGeogPointInst("POINT(5 5)@2000-01-02"),
351+
TGeogPointInst("POINT(6 6)@2000-01-05"),
352+
],
353+
TInterpolation.STEPWISE,
354+
timedelta(days=2),
355+
200000.0,
356+
),
357+
TGeogPointSeqSet(
358+
"Interp=Step;{[POINT(1 1)@2000-01-01], [POINT(5 5)@2000-01-02], [POINT(6 6)@2000-01-05]}"
359+
),
360+
),
361+
(
362+
(
363+
[
364+
TGeogPointInst("POINT(1 1)@2000-01-01"),
365+
TGeogPointInst("POINT(5 5)@2000-01-02"),
366+
TGeogPointInst("POINT(6 6)@2000-01-05"),
367+
],
368+
TInterpolation.LINEAR,
369+
None,
370+
),
371+
TGeogPointSeqSet(
372+
"{[POINT(1 1)@2000-01-01, POINT(5 5)@2000-01-02, POINT(6 6)@2000-01-05]}"
373+
),
374+
),
375+
(
376+
(
377+
[
378+
TGeogPointInst("POINT(1 1)@2000-01-01"),
379+
TGeogPointInst("POINT(5 5)@2000-01-02"),
380+
TGeogPointInst("POINT(6 6)@2000-01-05"),
381+
],
382+
TInterpolation.LINEAR,
383+
None,
384+
200000.0,
385+
),
386+
TGeogPointSeqSet(
387+
"{[POINT(1 1)@2000-01-01], [POINT(5 5)@2000-01-02, POINT(6 6)@2000-01-05]}"
388+
),
389+
),
390+
(
391+
(
392+
[
393+
TGeogPointInst("POINT(1 1)@2000-01-01"),
394+
TGeogPointInst("POINT(5 5)@2000-01-02"),
395+
TGeogPointInst("POINT(6 6)@2000-01-05"),
396+
],
397+
TInterpolation.LINEAR,
398+
timedelta(days=2),
399+
),
400+
TGeogPointSeqSet(
401+
"{[POINT(1 1)@2000-01-01, POINT(5 5)@2000-01-02], [POINT(6 6)@2000-01-05]}"
402+
),
403+
),
404+
(
405+
(
406+
[
407+
TGeogPointInst("POINT(1 1)@2000-01-01"),
408+
TGeogPointInst("POINT(5 5)@2000-01-02"),
409+
TGeogPointInst("POINT(6 6)@2000-01-05"),
410+
],
411+
TInterpolation.LINEAR,
412+
timedelta(days=2),
413+
200000.0,
414+
),
415+
TGeogPointSeqSet(
416+
"{[POINT(1 1)@2000-01-01], [POINT(5 5)@2000-01-02], [POINT(6 6)@2000-01-05]}"
417+
),
418+
),
419+
],
420+
ids=[
421+
"No Gaps Stepwise",
422+
"Value Gaps Stepwise",
423+
"Time Gaps Stepwise",
424+
"Value and Time Gaps Stepwise",
425+
"No Gaps Linear",
426+
"Value Gaps Linear",
427+
"Time Gaps Linear",
428+
"Value and Time Gaps Linear",
429+
],
430+
)
431+
def test_gaps_constructor(self, params, result):
432+
assert TGeogPointSeqSet.from_instants_with_gaps(*params) == result
433+
434+
@pytest.mark.parametrize(
435+
"params",
436+
[
437+
{"interpolation": TInterpolation.DISCRETE},
438+
],
439+
ids=[
440+
"Discrete Interpolation",
441+
],
442+
)
443+
def test_gaps_constructor_with_invalid_parameters_raises(self, params):
444+
instants = [
445+
TGeogPointInst(point="POINT(1 1)", timestamp="2000-01-01"),
446+
TGeogPointInst(point="POINT(5 5)", timestamp="2000-01-02"),
447+
TGeogPointInst(point="POINT(6 6)", timestamp="2000-01-03"),
448+
]
449+
with pytest.raises(MeosException):
450+
TGeogPointSeqSet.from_instants_with_gaps(instants, **params)
451+
300452
@pytest.mark.parametrize(
301453
"temporal",
302454
[tpi, tpds, tps, tpss, tpi3d, tpds3d, tps3d, tpss3d],
@@ -1812,10 +1964,7 @@ def test_round(self, temporal, expected):
18121964
[
18131965
(
18141966
TGeogPointInst("Point(42.84979 42.38153)@2019-09-01"),
1815-
TGeogPointInst(
1816-
"SRID=8426;"
1817-
"Point(42.84979 42.38153)@2019-09-01"
1818-
),
1967+
TGeogPointInst("SRID=8426;" "Point(42.84979 42.38153)@2019-09-01"),
18191968
),
18201969
(
18211970
TGeogPointSeq(

0 commit comments

Comments
 (0)