Skip to content

Commit c51c59a

Browse files
committed
Add TPoint Tests
1 parent 3abbb18 commit c51c59a

File tree

2 files changed

+306
-2
lines changed

2 files changed

+306
-2
lines changed

tests/main/tgeogpoint_test.py

Lines changed: 153 additions & 1 deletion
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],

tests/main/tgeompoint_test.py

Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66
import math
77
import numpy as np
8-
from pymeos_cffi import MeosInvalidArgValueError
8+
from pymeos_cffi import MeosInvalidArgValueError, MeosException
99
from shapely import Point, LineString, Polygon, MultiPoint, GeometryCollection
1010

1111
from pymeos import (
@@ -289,6 +289,158 @@ def test_instant_list_sequence_constructor(
289289
assert str(tps2) == expected
290290
assert tps2.interpolation() == interpolation
291291

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

0 commit comments

Comments
 (0)