-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interpolation or retrieval does not work at subsecond level #69
Comments
This was an issue in the |
Many thanks for the quick reply. I updated the cffi package. There were no errors on Linux, but on MacOS, there was a compilation error during installation. I will create a separate issue for that on the cffi repo. Now, when running the code below, it throws an error: import datetime
import pymeos
import pymeos_cffi
pymeos.pymeos_initialize()
print(pymeos_cffi.__version__)
t = pymeos.TGeomPointSeq(
"[POINT(295.9722900390625 654.239990234375)@2024-05-07 14:47:07-07, POINT(343.66021728515625 633.1279296875)@2024-05-07 14:47:07.1001-07, POINT(419.7856750488281 599.8984985351562)@2024-05-07 14:47:07.2002-07, POINT(483.23553466796875 565.5811767578125)@2024-05-07 14:47:07.3003-07, POINT(547.3091430664062 539.0184326171875)@2024-05-07 14:47:07.4004-07, POINT(607.9834594726562 513.4208374023438)@2024-05-07 14:47:07.5005-07, POINT(662.676513671875 490.9242858886719)@2024-05-07 14:47:07.6006-07, POINT(714.170654296875 475.9928894042969)@2024-05-07 14:47:07.7007-07, POINT(764.0394897460938 462.255126953125)@2024-05-07 14:47:07.8008-07, POINT(807.018310546875 448.92486572265625)@2024-05-07 14:47:07.9009-07, POINT(846.0618896484375 436.96124267578125)@2024-05-07 14:47:08.001-07]"
)
t.value_at_timestamp(datetime.datetime(2024, 5, 7, 14, 47, 7, 400400)) I get the following output 1.1.2
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
print(pymeos_cffi.__version__)
t = pymeos.TGeomPointSeq(
"[POINT(295.9722900390625 654.239990234375)@2024-05-07 14:47:07-07, POINT(343.66021728515625 633.1279296875)@2024-05-07 14:47:07.1001-07, POINT(419.7856750488281 599.8984985351562)@2024-05-07 14:47:07.2002-07, POINT(483.23553466796875 565.5811767578125)@2024-05-07 14:47:07.3003-07, POINT(547.3091430664062 539.0184326171875)@2024-05-07 14:47:07.4004-07, POINT(607.9834594726562 513.4208374023438)@2024-05-07 14:47:07.5005-07, POINT(662.676513671875 490.9242858886719)@2024-05-07 14:47:07.6006-07, POINT(714.170654296875 475.9928894042969)@2024-05-07 14:47:07.7007-07, POINT(764.0394897460938 462.255126953125)@2024-05-07 14:47:07.8008-07, POINT(807.018310546875 448.92486572265625)@2024-05-07 14:47:07.9009-07, POINT(846.0618896484375 436.96124267578125)@2024-05-07 14:47:08.001-07]"
) )
---> t.value_at_timestamp(datetime.datetime(2024, 5, 7, 14, 47, 7, 400400))
File ~/study-venv/lib/python3.10/site-packages/pymeos/main/tpoint.py:227, in TPoint.value_at_timestamp(self, timestamp, precision)
def value_at_timestamp(self, timestamp: datetime, precision: int = 15) -> shp.Point:
"""
Returns the value of the temporal point at the given timestamp.
(...)
tpoint_value_at_timestamp
"""
return gserialized_to_shapely_point(
tpoint_value_at_timestamptz(
self._inner, datetime_to_timestamptz(timestamp), True
)[0],
precision,
)
TypeError: 'NoneType' object is not subscriptable |
I think there are two separate issues here. One is that it crashes when the function returns Many thanks! |
Yes, many thanks. It now interpolates at the subsecond level. import datetime
import pymeos
pymeos.pymeos_initialize()
t = pymeos.TGeomPointSeq(
"[POINT(295.9722900390625 654.239990234375)@2024-05-07 14:47:07-07, POINT(343.66021728515625 633.1279296875)@2024-05-07 14:47:07.1001-07]"
)
print(t.value_at_timestamp(t.timestamps()[0] + datetime.timedelta(seconds=0.05))) prints |
Great! |
When trying to extract the value from TGeomPointSeq using the value_at_timestamp method, and the timestamp provided has a non-zero microseconds part, the microseconds would not be considered for interpolation or retrieval.
To Reproduce
Let tgps be equal to
TGeomPointSeq([POINT(295.9722900390625 654.239990234375)@2024-05-07 14:47:07-07, POINT(343.66021728515625 633.1279296875)@2024-05-07 14:47:07.1001-07, POINT(419.7856750488281 599.8984985351562)@2024-05-07 14:47:07.2002-07, POINT(483.23553466796875 565.5811767578125)@2024-05-07 14:47:07.3003-07, POINT(547.3091430664062 539.0184326171875)@2024-05-07 14:47:07.4004-07, POINT(607.9834594726562 513.4208374023438)@2024-05-07 14:47:07.5005-07, POINT(662.676513671875 490.9242858886719)@2024-05-07 14:47:07.6006-07, POINT(714.170654296875 475.9928894042969)@2024-05-07 14:47:07.7007-07, POINT(764.0394897460938 462.255126953125)@2024-05-07 14:47:07.8008-07, POINT(807.018310546875 448.92486572265625)@2024-05-07 14:47:07.9009-07, POINT(846.0618896484375 436.96124267578125)@2024-05-07 14:47:08.001-07])
, then callingtgps.value_at_timestamp(datetime.datetime(2024, 5, 7, 14, 47, 7, 400400))
would return<POINT (295.972 654.24)>
(the first point in the sequence) instead of the expected<POINT (547.30 539.01)>
(the value of the 5th instant in the sequence).Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: