|
5 | 5 | import numpy as np |
6 | 6 | import pytest |
7 | 7 | import shapely.geometry |
8 | | -from pymeos_cffi import MeosInvalidArgValueError |
| 8 | +from pymeos_cffi import MeosInvalidArgValueError, MeosException |
9 | 9 | from shapely import Point, LineString, set_srid |
10 | 10 |
|
11 | 11 | from pymeos import ( |
@@ -297,6 +297,158 @@ def test_instant_list_sequence_constructor( |
297 | 297 | assert str(tps2) == expected |
298 | 298 | assert tps2.interpolation() == interpolation |
299 | 299 |
|
| 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 | + |
300 | 452 | @pytest.mark.parametrize( |
301 | 453 | "temporal", |
302 | 454 | [tpi, tpds, tps, tpss, tpi3d, tpds3d, tps3d, tpss3d], |
@@ -1812,10 +1964,7 @@ def test_round(self, temporal, expected): |
1812 | 1964 | [ |
1813 | 1965 | ( |
1814 | 1966 | 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"), |
1819 | 1968 | ), |
1820 | 1969 | ( |
1821 | 1970 | TGeogPointSeq( |
|
0 commit comments