From 85f172460501f0c7cc519f106cfcf942d53141a1 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Wed, 9 Aug 2023 10:07:07 +0200 Subject: [PATCH 1/6] Tests for temporal types --- pymeos/pymeos/boxes/stbox.py | 57 +- pymeos/pymeos/boxes/tbox.py | 196 +++--- pymeos/pymeos/main/tfloat.py | 110 ++-- pymeos/pymeos/main/tint.py | 69 ++- pymeos/pymeos/main/tnumber.py | 130 ++-- pymeos/pymeos/main/tpoint.py | 12 + pymeos/pymeos/temporal/temporal.py | 58 +- pymeos/tests/boxes/tbox_test.py | 363 +++++------ pymeos/tests/main/tbool_test.py | 95 ++- pymeos/tests/main/tfloat_test.py | 579 ++++++++++++------ pymeos/tests/main/tgeogpoint_test.py | 400 +++++++++++- pymeos/tests/main/tgeompoint_test.py | 228 ++++--- pymeos/tests/main/tint_test.py | 437 ++++++++----- pymeos/tests/main/ttext_test.py | 119 +++- pymeos_cffi/pymeos_cffi/__init__.py | 47 +- .../pymeos_cffi/builder/build_helpers.py | 2 - pymeos_cffi/pymeos_cffi/builder/meos.h | 52 +- pymeos_cffi/pymeos_cffi/functions.py | 166 +++-- 18 files changed, 2089 insertions(+), 1031 deletions(-) diff --git a/pymeos/pymeos/boxes/stbox.py b/pymeos/pymeos/boxes/stbox.py index 92c4ac31..e8898e77 100644 --- a/pymeos/pymeos/boxes/stbox.py +++ b/pymeos/pymeos/boxes/stbox.py @@ -63,10 +63,14 @@ def _get_box(self, other: Union[Geometry, STBox, Temporal, Time], allow_space_on # ------------------------- Constructors ---------------------------------- def __init__(self, string: Optional[str] = None, *, - xmin: Optional[Union[str, float]] = None, xmax: Optional[Union[str, float]] = None, - ymin: Optional[Union[str, float]] = None, ymax: Optional[Union[str, float]] = None, - zmin: Optional[Union[str, float]] = None, zmax: Optional[Union[str, float]] = None, - tmin: Optional[Union[str, datetime]] = None, tmax: Optional[Union[str, datetime]] = None, + xmin: Optional[Union[str, float]] = None, + xmax: Optional[Union[str, float]] = None, + ymin: Optional[Union[str, float]] = None, + ymax: Optional[Union[str, float]] = None, + zmin: Optional[Union[str, float]] = None, + zmax: Optional[Union[str, float]] = None, + tmin: Optional[Union[str, datetime]] = None, + tmax: Optional[Union[str, datetime]] = None, tmin_inc: bool = True, tmax_inc: bool = True, geodetic: bool = False, srid: Optional[int] = None, _inner=None): @@ -226,15 +230,16 @@ def from_tpoint(temporal: TPoint) -> STBox: return STBox(_inner=tpoint_to_stbox(temporal._inner)) @staticmethod - def from_expanding_bounding_box(value: Union[Geometry, TPoint, STBox], expansion: float, - geodetic: Optional[bool] = False) -> STBox: + def from_expanding_bounding_box(value: Union[Geometry, TPoint, STBox], + expansion: float, geodetic: Optional[bool] = False) -> STBox: """ Returns a `STBox` from a `Geometry`, `TPoint` or `STBox` instance, expanding its bounding box by the given amount. Args: value: A `Geometry`, `TPoint` or `STBox` instance. expansion: The amount to expand the bounding box. - geodetic: Whether to create a geodetic or geometric `STBox`. Only used when value is a `Geometry` instance. + geodetic: Whether to create a geodetic or geometric `STBox`. + Only used when value is a `Geometry` instance. Returns: A new :class:`STBox` instance. @@ -596,7 +601,8 @@ def tscale(self, duration: timedelta) -> STBox: """ return self.shift_tscale(duration=duration) - def shift_tscale(self, shift: Optional[timedelta] = None, duration: Optional[timedelta] = None) -> STBox: + def shift_tscale(self, shift: Optional[timedelta] = None, + duration: Optional[timedelta] = None) -> STBox: """ Returns a new `STBox` with the time dimension shifted by `shift` and with duration `duration`. @@ -641,16 +647,15 @@ def round(self, maxdd : int = 0) -> STBox: return STBox(_inner=new_inner) # ------------------------- Set Operations -------------------------------- - def union(self, other: STBox, strict: bool = True) -> STBox: + def union(self, other: STBox, strict: Optional[bool] = True) -> STBox: """ - Returns the smallest spatio-temporal box that contains both ``self`` and `other`. + Returns the union of `self` with `other`. Fails if the union is not contiguous. Args: - other: The other :class:`STBox` to union with ``self``. - strict: If ``True``, the union will fail if the boxes are not overlapping. + other: spatiotemporal box to merge with Returns: - A new :class:`STBox` instance. + A :class:`STBox` instance. MEOS Functions: union_stbox_stbox @@ -659,32 +664,29 @@ def union(self, other: STBox, strict: bool = True) -> STBox: def __add__(self, other): """ - Returns the non-strict union of ``self`` and `other`. + Returns the union of `self` with `other`. Fails if the union is not contiguous. Args: - other: The spatiotemporal object to union with ``self``. + other: spatiotemporal box to merge with Returns: - An :class:`STBox` with the union of ``self`` and ``other``. + A :class:`STBox` instance. MEOS Functions: union_stbox_stbox - - See Also: - :meth:`STBox.union` """ - return self.union(other, strict=False) + return self.union(other) # TODO: Check returning None for empty intersection is the desired behaviour def intersection(self, other: STBox) -> Optional[STBox]: """ - Returns the intersection of ``self`` and `other`. + Returns the intersection of `self` with `other`. Args: - other: The other :class:`STBox` to intersect with ``self``. + other: temporal object to merge with Returns: - A new :class:`STBox` instance or ``None`` if the intersection is empty. + A :class:`STBox` instance if the instersection is not empty, `None` otherwise. MEOS Functions: intersection_stbox_stbox @@ -694,19 +696,16 @@ def intersection(self, other: STBox) -> Optional[STBox]: def __mul__(self, other): """ - Returns the intersection of ``self`` and `other`. + Returns the intersection of `self` with `other`. Args: - other: The spatiotemporal object to intersect with ``self``. + other: temporal object to merge with Returns: - An :class:`STBox` with the intersection of ``self`` and ``other``. + A :class:`STBox` instance if the instersection is not empty, `None` otherwise. MEOS Functions: intersection_stbox_stbox - - See Also: - :meth:`STBox.intersection` """ return self.intersection(other) diff --git a/pymeos/pymeos/boxes/tbox.py b/pymeos/pymeos/boxes/tbox.py index 783923f6..49f9eb74 100644 --- a/pymeos/pymeos/boxes/tbox.py +++ b/pymeos/pymeos/boxes/tbox.py @@ -15,11 +15,14 @@ class TBox: ``TBox`` objects can be created with a single argument of type string as in MobilityDB. - >>> TBox('TBox XT([0, 10),[2020-06-01, 2020-06-05])') + >>> TBox('TBOXINT XT([0, 10),[2020-06-01, 2020-06-05])') + >>> TBox('TBOXFLOAT XT([0, 10),[2020-06-01, 2020-06-05])') + >>> TBox('TBOX T([2020-06-01, 2020-06-05])') - Another possibility is to provide the ``xmin``/``xmax`` (of type str or float) and ``tmin``/``tmax`` (of type str or - datetime) named parameters, and optionally indicate whether the bounds are inclusive or exclusive (by default, - lower bounds are inclusive and upper bounds are exclusive): + Another possibility is to provide the ``xmin``/``xmax`` (of type str or + int/float) and ``tmin``/``tmax`` (of type str or datetime) named parameters, + and optionally indicate whether the bounds are inclusive or exclusive (by + default, lower bounds are inclusive and upper bounds are exclusive): >>> TBox(xmin=0, xmax=10, tmin='2020-06-01', tmax='2020-06-0') >>> TBox(xmin=0, xmax=10, tmin='2020-06-01', tmax='2020-06-0', xmax_inc=True, tmax_inc=True) @@ -41,8 +44,8 @@ def _inner_span(self): # ------------------------- Constructors ---------------------------------- def __init__(self, string: Optional[str] = None, *, - xmin: Optional[Union[str, float]] = None, - xmax: Optional[Union[str, float]] = None, + xmin: Optional[Union[str, int, float]] = None, + xmax: Optional[Union[str, int, float]] = None, tmin: Optional[Union[str, datetime]] = None, tmax: Optional[Union[str, datetime]] = None, xmin_inc: Optional[bool] = True, @@ -61,10 +64,13 @@ def __init__(self, string: Optional[str] = None, *, span = None period = None if xmin is not None and xmax is not None: - span = floatspan_make(float(xmin), float(xmax), xmin_inc, xmax_inc) + if isinstance(xmin, int) and isinstance(xmax, int): + span = intspan_make(xmin, xmax, xmin_inc, xmax_inc) + else: + span = floatspan_make(float(xmin), float(xmax), xmin_inc, xmax_inc) if tmin is not None and tmax is not None: period = Period(lower=tmin, upper=tmax, lower_inc=tmin_inc, upper_inc=tmax_inc)._inner - self._inner = tbox_make(period, span) + self._inner = tbox_make(span, period) def __copy__(self) -> TBox: """ @@ -222,21 +228,6 @@ def from_tnumber(temporal: TNumber) -> TBox: return TBox(_inner=tnumber_to_tbox(temporal._inner)) # ------------------------- Output ---------------------------------------- - def to_str(self, max_decimals=15) -> str: - """ - Returns a string representation of `self` with a maximum number of decimals. - - Args: - max_decimals: The maximum number of decimals. - - Returns: - A string representation of `self`. - - MEOS Functions: - tbox_out - """ - return tbox_out(self._inner, max_decimals) - def __str__(self, max_decimals: int = 15): """ Returns a string representation of ``self``. @@ -501,14 +492,15 @@ def tscale(self, duration: timedelta) -> TBox: """ return self.shift_tscale(duration=duration) - def shift_tscale(self, shift: Optional[timedelta] = None, duration: Optional[timedelta] = None) -> TBox: + def shift_tscale(self, shift: Optional[timedelta] = None, + duration: Optional[timedelta] = None) -> TBox: """ Returns a new TBox with the temporal span shifted by `shift` and duration `duration`. Examples: - >>> tbox = TBox('TBox XT([0, 10),[2020-06-01, 2020-06-05])') + >>> tbox = TBox('TBoxInt XT([0, 10),[2020-06-01, 2020-06-05])') >>> tbox.shift_tscale(shift=timedelta(days=2), duration=timedelta(days=4)) - >>> 'TBOX XT([0, 10),[2020-06-03 00:00:00+02, 2020-06-07 00:00:00+02])' + >>> 'TBOXINT XT([0, 10),[2020-06-03 00:00:00+02, 2020-06-07 00:00:00+02])' Args: shift: :class:`datetime.timedelta` instance to shift the start of the temporal span @@ -550,6 +542,69 @@ def round(self, maxdd : int = 0) -> STBox: tbox_round(new_inner, maxdd) return TBox(_inner=new_inner) + # ------------------------- Set Operations -------------------------------- + def union(self, other: TBox, strict: Optional[bool] = True) -> TBox: + """ + Returns the union of `self` with `other`. Fails if the union is not contiguous. + + Args: + other: temporal object to merge with + + Returns: + A :class:`TBox` instance. + + MEOS Functions: + union_tbox_tbox + """ + return TBox(_inner=union_tbox_tbox(self._inner, other._inner, strict)) + + def __add__(self, other): + """ + Returns the union of `self` with `other`. Fails if the union is not contiguous. + + Args: + other: temporal object to merge with + + Returns: + A :class:`TBox` instance. + + MEOS Functions: + union_tbox_tbox + """ + return self.union(other) + + # TODO: Check returning None for empty intersection is the desired behaviour + def intersection(self, other: TBox) -> Optional[TBox]: + """ + Returns the intersection of `self` with `other`. + + Args: + other: temporal object to merge with + + Returns: + A :class:`TBox` instance if the instersection is not empty, `None` otherwise. + + MEOS Functions: + intersection_tbox_tbox + """ + result = intersection_tbox_tbox(self._inner, other._inner) + return TBox(_inner=result) if result else None + + def __mul__(self, other): + """ + Returns the intersection of `self` with `other`. + + Args: + other: temporal object to merge with + + Returns: + A :class:`TBox` instance if the instersection is not empty, `None` otherwise. + + MEOS Functions: + intersection_tbox_tbox + """ + return self.intersection(other) + # ------------------------- Topological Operations ------------------------ def is_adjacent(self, other: Union[int, float, intrange, floatrange, TBox, TNumber]) -> bool: """ @@ -557,11 +612,11 @@ def is_adjacent(self, other: Union[int, float, intrange, floatrange, TBox, TNumb and only one of them contains it. Examples: - >>> TBox('TBox XT([0, 1], [2012-01-01, 2012-01-02))').is_adjacent(TBox('TBox XT([0, 1], [2012-01-02, 2012-01-03])')) + >>> TBox('TBoxInt XT([0, 1], [2012-01-01, 2012-01-02))').is_adjacent(TBox('TBoxInt XT([0, 1], [2012-01-02, 2012-01-03])')) >>> True - >>> TBox('TBox XT([0, 1], [2012-01-01, 2012-01-02])').is_adjacent(TBox('TBox XT([0, 1], [2012-01-02, 2012-01-03])')) + >>> TBox('TBoxInt XT([0, 1], [2012-01-01, 2012-01-02])').is_adjacent(TBox('TBoxInt XT([0, 1], [2012-01-02, 2012-01-03])')) >>> False # Both contain bound - >>> TBox('TBox XT([0, 1), [2012-01-01, 2012-01-02))').is_adjacent(TBox('TBox XT([1, 2], [2012-01-02, 2012-01-03])') + >>> TBox('TBoxInt XT([0, 1), [2012-01-01, 2012-01-02))').is_adjacent(TBox('TBoxInt XT([1, 2], [2012-01-02, 2012-01-03])') >>> False # Adjacent in both bounds Args: @@ -594,11 +649,11 @@ def is_contained_in(self, container: Union[TBox, TNumber]) -> bool: Returns whether ``self`` is contained in ``container``. Examples: - >>> TBox('TBox XT([1, 2], [2012-01-02, 2012-01-03])').is_contained_in(TBox('TBox XT([1, 4], [2012-01-01, 2012-01-04])')) + >>> TBox('TBoxInt XT([1, 2], [2012-01-02, 2012-01-03])').is_contained_in(TBox('TBoxInt XT([1, 4], [2012-01-01, 2012-01-04])')) >>> True - >>> TBox('TBox XT((1, 2), (2012-01-01, 2012-01-02))').is_contained_in(TBox('TBox XT([1, 4], [2012-01-01, 2012-01-02])')) + >>> TBox('TBoxFloat XT((1, 2), (2012-01-01, 2012-01-02))').is_contained_in(TBox('TBoxFloat XT([1, 4], [2012-01-01, 2012-01-02])')) >>> True - >>> TBox('TBox XT([1, 2], [2012-01-01, 2012-01-02])').is_contained_in(TBox('TBox XT((1, 2), (2012-01-01, 2012-01-02))')) + >>> TBox('TBoxFloat XT([1, 2], [2012-01-01, 2012-01-02])').is_contained_in(TBox('TBoxFloat XT((1, 2), (2012-01-01, 2012-01-02))')) >>> False Args: @@ -622,11 +677,11 @@ def contains(self, content: Union[TBox, TNumber]) -> bool: Returns whether ``self`` temporally contains ``content``. Examples: - >>> TBox('TBox XT([1, 4], [2012-01-01, 2012-01-04]').contains(TBox('TBox XT([2, 3], [2012-01-02, 2012-01-03]')) + >>> TBox('TBoxInt XT([1, 4], [2012-01-01, 2012-01-04]').contains(TBox('TBoxInt XT([2, 3], [2012-01-02, 2012-01-03]')) >>> True - >>> TBox('TBox XT([1, 2], [2012-01-01, 2012-01-02]').contains(TBox('TBox XT((1, 2), (2012-01-01, 2012-01-02)')) + >>> TBox('TBoxFloat XT([1, 2], [2012-01-01, 2012-01-02]').contains(TBox('TBoxFloat XT((1, 2), (2012-01-01, 2012-01-02)')) >>> True - >>> TBox('TBox XT((1, 2), (2012-01-01, 2012-01-02)').contains(TBox('TBox XT([1, 2], [2012-01-01, 2012-01-02]')) + >>> TBox('TBoxFloat XT((1, 2), (2012-01-01, 2012-01-02)').contains(TBox('TBoxFloat XT([1, 2], [2012-01-01, 2012-01-02]')) >>> False Args: @@ -650,11 +705,11 @@ def __contains__(self, item): Returns whether ``self`` temporally contains ``item``. Examples: - >>> TBox('TBox XT([2, 3], [2012-01-02, 2012-01-03]') in TBox('TBox XT([1, 4], [2012-01-01, 2012-01-04]') + >>> TBox('TBoxInt XT([2, 3], [2012-01-02, 2012-01-03]') in TBox('TBoxInt XT([1, 4], [2012-01-01, 2012-01-04]') >>> True - >>> TBox('TBox XT((1, 2), (2012-01-01, 2012-01-02)') in TBox('TBox XT([1, 2], [2012-01-01, 2012-01-02]') + >>> TBox('TBoxFloat XT((1, 2), (2012-01-01, 2012-01-02)') in TBox('TBoxFloat XT([1, 2], [2012-01-01, 2012-01-02]') >>> True - >>> TBox('TBox XT([1, 2], [2012-01-01, 2012-01-02]') in TBox('TBox XT((1, 2), (2012-01-01, 2012-01-02)') + >>> TBox('TBoxFloat XT([1, 2], [2012-01-01, 2012-01-02]') in TBox('TBoxFloat XT((1, 2), (2012-01-01, 2012-01-02)') >>> False Args: @@ -688,7 +743,6 @@ def overlaps(self, other: Union[TBox, TNumber]) -> bool: else: raise TypeError(f'Operation not supported with type {other.__class__}') - # ------------------------- Position Operations --------------------------- def is_same(self, other: Union[TBox, TNumber]) -> bool: """ Returns whether ``self`` is the same as ``other``. @@ -710,6 +764,7 @@ def is_same(self, other: Union[TBox, TNumber]) -> bool: else: raise TypeError(f'Operation not supported with type {other.__class__}') + # ------------------------- Position Operations --------------------------- def is_left(self, other: Union[TBox, TNumber]) -> bool: """ Returns whether ``self`` is strictly to the left of ``other``. @@ -874,69 +929,6 @@ def is_over_or_after(self, other: Union[TBox, TNumber]) -> bool: else: raise TypeError(f'Operation not supported with type {other.__class__}') - # ------------------------- Set Operations -------------------------------- - def union(self, other: TBox) -> TBox: - """ - Returns the union of `self` with `other`. Fails if the union is not contiguous. - - Args: - other: temporal object to merge with - - Returns: - A :class:`TBox` instance. - - MEOS Functions: - union_tbox_tbox - """ - return TBox(_inner=union_tbox_tbox(self._inner, other._inner)) - - def __add__(self, other): - """ - Returns the union of `self` with `other`. Fails if the union is not contiguous. - - Args: - other: temporal object to merge with - - Returns: - A :class:`TBox` instance. - - MEOS Functions: - union_tbox_tbox - """ - return self.union(other) - - # TODO: Check returning None for empty intersection is the desired behaviour - def intersection(self, other: TBox) -> Optional[TBox]: - """ - Returns the intersection of `self` with `other`. - - Args: - other: temporal object to merge with - - Returns: - A :class:`TBox` instance if the instersection is not empty, `None` otherwise. - - MEOS Functions: - intersection_tbox_tbox - """ - result = intersection_tbox_tbox(self._inner, other._inner) - return TBox(_inner=result) if result else None - - def __mul__(self, other): - """ - Returns the intersection of `self` with `other`. - - Args: - other: temporal object to merge with - - Returns: - A :class:`TBox` instance if the instersection is not empty, `None` otherwise. - - MEOS Functions: - intersection_tbox_tbox - """ - return self.intersection(other) - # ------------------------- Distance Operations --------------------------- def nearest_approach_distance(self, other: Union[TBox, TNumber]) -> float: """ diff --git a/pymeos/pymeos/main/tfloat.py b/pymeos/pymeos/main/tfloat.py index 2d009f44..0a74e9ff 100644 --- a/pymeos/pymeos/main/tfloat.py +++ b/pymeos/pymeos/main/tfloat.py @@ -94,35 +94,52 @@ def __str__(self, max_decimals=15): """ return tfloat_out(self._inner, max_decimals) - def to_str(self, max_decimals=15) -> str: + def as_wkt(self, precision: int = 15) -> str: """ - Returns a string representation of `self` with a maximum number of decimals. + Returns a WKT representation of `self`. Args: - max_decimals: The maximum number of decimals. + precision: The number of decimals to use. Returns: - A string representation of `self`. + A WKT representation of `self`. MEOS Functions: tfloat_out """ - return tfloat_out(self._inner, max_decimals) + return tfloat_out(self._inner, precision) - def as_wkt(self, precision: int = 15) -> str: + # ------------------------- Conversions ---------------------------------- + def to_tint(self) -> TInt: """ - Returns a WKT representation of `self`. + Returns a new temporal integer with the values of `self` floored. + This operation can only be performed when the interpolation is stepwise or discrete. - Args: - precision: The number of decimals to use. + Returns: + A new temporal integer. + + MEOS Functions: + tfloat_to_tint + + Raises: + ValueError: If the interpolation is linear. + """ + from ..factory import _TemporalFactory + if self.interpolation() == TInterpolation.LINEAR: + raise ValueError("Cannot convert a temporal float with linear interpolation to a temporal integer") + return _TemporalFactory.create_temporal(tfloat_to_tint(self._inner)) + + def to_floatrange(self) -> floatrange: + """ + Returns value span of `self`. Returns: - A WKT representation of `self`. + An :class:`floatrange` with the value span of `self`. MEOS Functions: - tfloat_out + tnumber_to_span """ - return tfloat_out(self._inner, precision) + return floatspan_to_floatrange(tnumber_to_span(self._inner)) # ------------------------- Accessors ------------------------------------- def value_range(self) -> floatrange: @@ -147,8 +164,9 @@ def value_ranges(self) -> List[floatrange]: MEOS Functions: tfloat_spanset """ - spanset = tnumber_values(self._inner) - spans, count = spanset_spans(spanset) + spanset = tnumber_valuespans(self._inner) + spans = spanset_spans(spanset) + count = spanset_num_spans(spanset) return [floatspan_to_floatrange(spans[i]) for i in range(count)] def start_value(self) -> float: @@ -601,31 +619,37 @@ def temporal_greater(self, other: Union[int, float, Temporal]) -> Temporal: # ------------------------- Restrictions ---------------------------------- def at(self, other: Union[int, float, List[int], List[float], - intrange, floatrange, List[intrange], List[floatrange], TBox, Time]) -> TFloat: + floatrange, List[floatrange], TBox, Time]) -> TFloat: """ - Returns a new temporal float with the values of `self` restricted to the time or value `other`. + Returns a new temporal float with the values of `self` restricted to the value or time `other`. Args: - other: Time or value to restrict to. + other: Value or time to restrict to. Returns: A new temporal float. MEOS Functions: - tfloat_at_value, temporal_at_timestamp, temporal_at_timestampset, temporal_at_period, temporal_at_periodset + tfloat_at_value, tfloat_at_values, tfloat_at_span, tfloat_at_spanset, + temporal_at_timestamp, temporal_at_timestampset, temporal_at_period, + temporal_at_periodset """ if isinstance(other, int) or isinstance(other, float): result = tfloat_at_value(self._inner, float(other)) - elif isinstance(other, list) and (isinstance(other[0], float) or isinstance(other[0], int)): - # result = tfloat_at_values(self._inner, [float(x) for x in other]) - results = [tfloat_at_value(self._inner, float(value)) for value in other if other is not None] + elif isinstance(other, floatrange): + result = tnumber_at_span(self._inner, floatrange_to_floatspan(other)) + elif isinstance(other, list) and (isinstance(other[0], int) or isinstance(other[0], float)): + results = [tfloat_at_value(self._inner, float(other)) for value in other if other is not None] + result = temporal_merge_array(results, len(results)) + elif isinstance(other, list) and (isinstance(other[0], floatrange) or isinstance(other[0], intrange)): + results = [tnumber_at_span(self._inner, value) for value in other if other is not None] result = temporal_merge_array(results, len(results)) else: return super().at(other) return Temporal._factory(result) - def minus(self, other: Union[ - int, float, List[float], intrange, floatrange, List[intrange], List[floatrange], TBox, Time]) -> Temporal: + def minus(self, other: Union[int, float, List[int], List[float], + floatrange, List[floatrange], TBox, Time]) -> Temporal: """ Returns a new temporal float with the values of `self` restricted to the complement of the time or value `other`. @@ -637,11 +661,14 @@ def minus(self, other: Union[ A new temporal float. MEOS Functions: - tfloat_minus_value, temporal_minus_timestamp, temporal_minus_timestampset, temporal_minus_period, - temporal_minus_periodset + tfloat_minus_value, tnumber_minus_span, + temporal_minus_timestamp, temporal_minus_timestampset, + temporal_minus_period, temporal_minus_periodset """ if isinstance(other, int) or isinstance(other, float): result = tfloat_minus_value(self._inner, float(other)) + elif isinstance(other, floatrange): + result = tnumber_minus_span(self._inner, floatrange_to_floatspan(other)) elif isinstance(other, list) and isinstance(other[0], float): result = reduce(tfloat_minus_value, other, self._inner) else: @@ -676,38 +703,7 @@ def derivative(self) -> TFloat: from ..factory import _TemporalFactory return _TemporalFactory.create_temporal(tfloat_derivative(self._inner)) - # ------------------------- Conversions ---------------------------------- - def to_tint(self) -> TInt: - """ - Returns a new temporal integer with the values of `self` floored. - This operation can only be performed when the interpolation is stepwise or discrete. - - Returns: - A new temporal integer. - - MEOS Functions: - tfloat_to_tint - - Raises: - ValueError: If the interpolation is linear. - """ - from ..factory import _TemporalFactory - if self.interpolation() == TInterpolation.LINEAR: - raise ValueError("Cannot convert a temporal float with linear interpolation to a temporal integer") - return _TemporalFactory.create_temporal(tfloat_to_tint(self._inner)) - - def to_floatrange(self) -> floatrange: - """ - Returns value span of `self`. - - Returns: - An :class:`floatrange` with the value span of `self`. - - MEOS Functions: - tnumber_to_span - """ - return floatspan_to_floatrange(tnumber_to_span(self._inner)) - + # ------------------------- Transformations ---------------------------------- def to_degrees(self, normalize: bool = True) -> TFloat: """ Returns a copy of `self` converted from radians to degrees. diff --git a/pymeos/pymeos/main/tint.py b/pymeos/pymeos/main/tint.py index 6b027ed1..ff8a7b0c 100644 --- a/pymeos/pymeos/main/tint.py +++ b/pymeos/pymeos/main/tint.py @@ -105,6 +105,32 @@ def as_wkt(self): """ return tint_out(self._inner) + # ------------------------- Conversions ---------------------------------- + def to_tfloat(self) -> TFloat: + """ + Returns a new temporal float with the values of `self`. + + Returns: + A new temporal float. + + MEOS Functions: + tint_to_tfloat + """ + from ..factory import _TemporalFactory + return _TemporalFactory.create_temporal(tint_to_tfloat(self._inner)) + + def to_intrange(self) -> intrange: + """ + Returns value span of `self`. + + Returns: + An :class:`intrange` with the value span of `self`. + + MEOS Functions: + tnumber_to_span + """ + return intspan_to_intrange(tnumber_to_span(self._inner)) + # ------------------------- Accessors ------------------------------------- def value_range(self) -> intrange: """ @@ -118,6 +144,21 @@ def value_range(self) -> intrange: """ return self.to_intrange() + def value_ranges(self) -> List[intrange]: + """ + Returns the value spans of `self` taking into account gaps. + + Returns: + A list of :class:`intrange` with the value spans of `self`. + + MEOS Functions: + tint_spanset + """ + spanset = tnumber_valuespans(self._inner) + spans = spanset_spans(spanset) + count = spanset_num_spans(spanset) + return [intspan_to_intrange(spans[i]) for i in range(count)] + def start_value(self) -> int: """ Returns the start value of `self`. @@ -448,7 +489,7 @@ def never_greater_or_equal(self, value: int) -> bool: MEOS Functions: tint_always_lt """ - return (self._inner, value) + return tint_always_lt(self._inner, value) def never_greater(self, value: int) -> bool: """ @@ -658,32 +699,6 @@ def nearest_approach_distance(self, other: Union[int, float, TNumber, TBox]) -> else: return super().nearest_approach_distance(other) - # ------------------------- Conversions ---------------------------------- - def to_tfloat(self) -> TFloat: - """ - Returns a new temporal float with the values of `self`. - - Returns: - A new temporal float. - - MEOS Functions: - tint_to_tfloat - """ - from ..factory import _TemporalFactory - return _TemporalFactory.create_temporal(tint_to_tfloat(self._inner)) - - def to_intrange(self) -> intrange: - """ - Returns value span of `self`. - - Returns: - An :class:`intrange` with the value span of `self`. - - MEOS Functions: - tnumber_to_span - """ - return intspan_to_intrange(tnumber_to_span(self._inner)) - # ------------------------- Split Operations ------------------------------ def value_split(self, size: int, start: Optional[int] = 0) -> List[TInt]: """ diff --git a/pymeos/pymeos/main/tnumber.py b/pymeos/pymeos/main/tnumber.py index 87e640b6..3464f5f0 100644 --- a/pymeos/pymeos/main/tnumber.py +++ b/pymeos/pymeos/main/tnumber.py @@ -11,6 +11,7 @@ if TYPE_CHECKING: from ..boxes import TBox from ..time import Time + from .tint import TInt from .tfloat import TFloat TBase = TypeVar('TBase', int, float) @@ -36,6 +37,30 @@ def bounding_box(self) -> TBox: from ..boxes import TBox return TBox(_inner=tnumber_to_tbox(self._inner)) + def integral(self) -> float: + """ + Returns the integral of `self`. + + Returns: + The integral of `self`. + + MEOS Function: + tnumber_integral + """ + return tnumber_integral(self._inner) + + def time_weighted_average(self) -> float: + """ + Returns the time weighted average of `self`. + + Returns: + The time weighted average of `self`. + + MEOS Function: + tnumber_twavg + """ + return tnumber_twavg(self._inner) + # ------------------------- Restrictions ---------------------------------- def at(self, other: Union[intrange, floatrange, List[intrange], List[floatrange], TBox, Time]) -> TG: """ @@ -176,10 +201,12 @@ def add(self, other: Union[int, float, TNumber]) -> TNumber: Returns: A new temporal object of the same subtype as `self`. """ - if isinstance(other, int): - result = add_tnumber_int(self._inner, other) - elif isinstance(other, float): - result = add_tnumber_float(self._inner, other) + from .tint import TInt + from .tfloat import TFloat + if isinstance(self, TInt) and isinstance(other, int): + result = add_tint_int(self._inner, other) + elif isinstance(self, TFloat) and isinstance(other, (int, float)): + result = add_tfloat_float(self._inner, float(other)) elif isinstance(other, TNumber): result = add_tnumber_tnumber(self._inner, other._inner) else: @@ -199,10 +226,12 @@ def radd(self, other: Union[int, float]) -> TNumber: MEOS Functions: add_int_tint, add_float_tfloat """ - if isinstance(other, int): - result = add_int_tnumber(other, self._inner) - elif isinstance(other, float): - result = add_float_tnumber(other, self._inner) + from .tint import TInt + from .tfloat import TFloat + if isinstance(self, TInt) and isinstance(other, int): + result = add_int_tint(other, self._inner) + elif isinstance(self, TFloat) and isinstance(other, (int, float)): + result = add_float_tfloat(float(other), self._inner) else: raise TypeError(f'Operation not supported with type {other.__class__}') return Temporal._factory(result) @@ -220,10 +249,12 @@ def sub(self, other: Union[int, float, TNumber]) -> TNumber: MEOS Functions: sub_tint_int, sub_tfloat_float, sub_tnumber_tnumber """ - if isinstance(other, int): - result = sub_tnumber_int(self._inner, other) - elif isinstance(other, float): - result = sub_tnumber_float(self._inner, other) + from .tint import TInt + from .tfloat import TFloat + if isinstance(self, TInt) and isinstance(other, int): + result = sub_tint_int(self._inner, other) + elif isinstance(self, TFloat) and isinstance(other, (int, float)): + result = sub_tfloat_float(self._inner, float(other)) elif isinstance(other, TNumber): result = sub_tnumber_tnumber(self._inner, other._inner) else: @@ -243,10 +274,12 @@ def rsub(self, other: Union[int, float]) -> TNumber: MEOS Functions: sub_int_tint, sub_float_tfloat """ - if isinstance(other, int): - result = sub_int_tnumber(other, self._inner) - elif isinstance(other, float): - result = sub_float_tnumber(other, self._inner) + from .tint import TInt + from .tfloat import TFloat + if isinstance(self, TInt) and isinstance(other, int): + result = sub_int_tint(other, self._inner) + elif isinstance(self, TFloat) and isinstance(other, (int, float)): + result = sub_float_tfloat(float(other), self._inner) else: raise TypeError(f'Operation not supported with type {other.__class__}') return Temporal._factory(result) @@ -264,10 +297,12 @@ def mul(self, other: Union[int, float, TNumber]) -> TNumber: MEOS Functions: mult_tint_int, mult_tfloat_float, mult_tnumber_tnumber """ - if isinstance(other, int): - result = mult_tnumber_int(self._inner, other) - elif isinstance(other, float): - result = mult_tnumber_float(self._inner, other) + from .tint import TInt + from .tfloat import TFloat + if isinstance(self, TInt) and isinstance(other, int): + result = mult_tint_int(self._inner, other) + elif isinstance(self, TFloat) and isinstance(other, (int, float)): + result = mult_tfloat_float(self._inner, float(other)) elif isinstance(other, TNumber): result = mult_tnumber_tnumber(self._inner, other._inner) else: @@ -287,10 +322,12 @@ def rmul(self, other: Union[int, float]) -> TNumber: MEOS Functions: mult_int_tint, mult_float_tfloat """ - if isinstance(other, int): - result = mult_int_tnumber(other, self._inner) - elif isinstance(other, float): - result = mult_float_tnumber(other, self._inner) + from .tint import TInt + from .tfloat import TFloat + if isinstance(self, TInt) and isinstance(other, int): + result = mult_int_tint(other, self._inner) + elif isinstance(self, TFloat) and isinstance(other, (int, float)): + result = mult_float_tfloat(float(other), self._inner) else: raise TypeError(f'Operation not supported with type {other.__class__}') return Temporal._factory(result) @@ -308,10 +345,12 @@ def div(self, other: Union[int, float, TNumber]) -> TNumber: MEOS Functions: div_tint_int, div_tfloat_float, div_tnumber_tnumber """ - if isinstance(other, int): - result = div_tnumber_int(self._inner, other) - elif isinstance(other, float): - result = div_tnumber_float(self._inner, other) + from .tint import TInt + from .tfloat import TFloat + if isinstance(self, TInt) and isinstance(other, int): + result = div_tint_int(self._inner, other) + elif isinstance(self, TFloat) and isinstance(other, (int, float)): + result = div_tfloat_float(self._inner, float(other)) elif isinstance(other, TNumber): result = div_tnumber_tnumber(self._inner, other._inner) else: @@ -331,10 +370,12 @@ def rdiv(self, other: Union[int, float]) -> TNumber: MEOS Functions: div_int_tint, div_float_tfloat """ - if isinstance(other, int): - result = div_int_tnumber(other, self._inner) - elif isinstance(other, float): - result = div_float_tnumber(other, self._inner) + from .tint import TInt + from .tfloat import TFloat + if isinstance(self, TInt) and isinstance(other, int): + result = div_int_tint(other, self._inner) + elif isinstance(self, TFloat) and isinstance(other, (int, float)): + result = div_float_tfloat(float(other), self._inner) else: raise TypeError(f'Operation not supported with type {other.__class__}') return Temporal._factory(result) @@ -530,28 +571,3 @@ def nearest_approach_distance(self, other: Union[int, float, TNumber, TBox]) -> else: raise TypeError(f'Operation not supported with type {other.__class__}') - # ------------------------- Aggregate Operations -------------------------- - def integral(self) -> float: - """ - Returns the integral of `self`. - - Returns: - The integral of `self`. - - MEOS Function: - tnumber_integral - """ - return tnumber_integral(self._inner) - - def time_weighted_average(self) -> float: - """ - Returns the time weighted average of `self`. - - Returns: - The time weighted average of `self`. - - MEOS Function: - tnumber_twavg - """ - return tnumber_twavg(self._inner) - diff --git a/pymeos/pymeos/main/tpoint.py b/pymeos/pymeos/main/tpoint.py index d34bcda1..0d0084a0 100644 --- a/pymeos/pymeos/main/tpoint.py +++ b/pymeos/pymeos/main/tpoint.py @@ -318,6 +318,18 @@ def bearing(self, other: Union[pg.Geometry, shpb.BaseGeometry, TPoint]) -> TFloa raise TypeError(f'Operation not supported with type {other.__class__}') return Temporal._factory(result) + def direction(self) -> float: + """ + Returns the azimuth of the temporal point between the start and end locations. + + Returns: + A new :class:`TFloatSeqSet` indicating the direction of the temporal point. + + MEOS Functions: + tpoint_direction + """ + return tpoint_direction(self._inner) + def azimuth(self) -> TFloatSeqSet: """ Returns the temporal azimuth of the temporal point. diff --git a/pymeos/pymeos/temporal/temporal.py b/pymeos/pymeos/temporal/temporal.py index dd8fbad0..42e0b9a0 100644 --- a/pymeos/pymeos/temporal/temporal.py +++ b/pymeos/pymeos/temporal/temporal.py @@ -178,7 +178,8 @@ def as_wkt(self) -> str: """ pass - def as_mfjson(self, with_bbox: bool = True, flags: int = 3, precision: int = 6, srs: Optional[str] = None) -> str: + def as_mfjson(self, with_bbox: bool = True, flags: int = 3, + precision: int = 6, srs: Optional[str] = None) -> str: """ Returns the temporal object as a MF-JSON string. @@ -528,6 +529,58 @@ def shift_tscale(self, shift: Optional[timedelta] = None, duration: Optional[tim ) return Temporal._factory(scaled) + def temporal_sample(self, duration: Union[str, timedelta], + start: Optional[Union[str, datetime]] = None) -> TG: + """ + Returns a new :class:`Temporal` downsampled with respect to ``duration``. + + Args: + duration: A :class:`str` or :class:`timedelta` with the duration of the temporal tiles. + start: A :class:`str` or :class:`datetime` with the start time of the temporal tiles. If None, the start + time of `self` is used. + + MEOS Functions: + temporal_tsample + """ + if start is None: + st = temporal_start_timestamp(self._inner) + elif isinstance(start, datetime): + st = datetime_to_timestamptz(start) + else: + st = pg_timestamptz_in(start, -1) + if isinstance(duration, timedelta): + dt = timedelta_to_interval(duration) + else: + pg_interval_in(duration, -1) + result = temporal_tsample(self._inner, dt, st) + return Temporal._factory(result) + + def temporal_precision(self, duration: Union[str, timedelta], + start: Optional[Union[str, datetime]] = None) -> TG: + """ + Returns a new :class:`Temporal` with precision reduced to ``duration``. + + Args: + duration: A :class:`str` or :class:`timedelta` with the duration of the temporal tiles. + start: A :class:`str` or :class:`datetime` with the start time of the temporal tiles. If None, the start + time of `self` is used. + + MEOS Functions: + temporal_tprecision + """ + if start is None: + st = temporal_start_timestamp(self._inner) + elif isinstance(start, datetime): + st = datetime_to_timestamptz(start) + else: + st = pg_timestamptz_in(start, -1) + if isinstance(duration, timedelta): + dt = timedelta_to_interval(duration) + else: + pg_interval_in(duration, -1) + result = temporal_tprecision(self._inner, dt, st) + return Temporal._factory(result) + def to_instant(self) -> TI: """ Returns `self` as a :class:`TInstant`. @@ -1099,7 +1152,8 @@ def time_split_n(self, n: int) -> List[TG]: from ..factory import _TemporalFactory return [_TemporalFactory.create_temporal(tiles[i]) for i in range(new_count)] - def stops(self, max_distance: float, min_duration: timedelta) -> TSS: + def stops(self, max_distance: Optional[float] = 0.0, + min_duration: Optional[timedelta] = timedelta()) -> TSS: """ Return the subsequences where the objects stay within an area with a given maximum size for at least the specified duration. diff --git a/pymeos/tests/boxes/tbox_test.py b/pymeos/tests/boxes/tbox_test.py index c611950e..7c12bc1e 100644 --- a/pymeos/tests/boxes/tbox_test.py +++ b/pymeos/tests/boxes/tbox_test.py @@ -39,21 +39,22 @@ def assert_tbox_equality(tbox: TBox, if tmax_inc is not None: assert tbox.tmax_inc() == tmax_inc + class TestTBoxConstructors(TestTBox): - tbx = TBox('TBOX X([1,2])') + tbfx = TBox('TBOXFLOAT X([1,2])') tbt = TBox('TBOX T([2019-09-01,2019-09-02])') - tbxt = TBox('TBOX XT([1,2],[2019-09-01,2019-09-02])') + tbfxt = TBox('TBOXFLOAT XT([1,2],[2019-09-01,2019-09-02])') @pytest.mark.parametrize( 'source, type, expected', [ - ('TBox X([1,2])', TBox, 'TBOX X([1, 2])'), - ('TBox T([2019-09-01,2019-09-02])', TBox, + ('TBOXFLOAT X([1,2])', TBox, 'TBOXFLOAT X([1, 2])'), + ('TBOX T([2019-09-01,2019-09-02])', TBox, 'TBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), - ('TBox XT([1,2],[2019-09-01,2019-09-02])', TBox, - 'TBOX XT([1, 2],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])') + ('TBOXFLOAT XT([1,2],[2019-09-01,2019-09-02])', TBox, + 'TBOXFLOAT XT([1, 2],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])') ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_string_constructor(self, source, type, expected): tb = type(source) @@ -71,10 +72,10 @@ def test_hexwkb_constructor(self): @pytest.mark.parametrize( 'value, expected', [ - (1, 'TBOX X([1, 1])'), - (1.5, 'TBOX X([1.5, 1.5])'), - (intrange(1, 2, True, True), 'TBOX X([1, 2])'), - (floatrange(1.5, 2.5, True, True), 'TBOX X([1.5, 2.5])'), + (1, 'TBOXINT X([1, 2))'), + (1.5, 'TBOXFLOAT X([1.5, 1.5])'), + (intrange(1, 2, True, True), 'TBOXINT X([1, 3))'), + (floatrange(1.5, 2.5, True, True), 'TBOXFLOAT X([1.5, 2.5])'), ], ids=['int', 'float', 'intrange', 'floatrange'] ) @@ -106,21 +107,21 @@ def test_from_value_constructor(self, value, expected): # 'value, time, expected', # [ # (1, datetime(2019, 9, 1), - # 'TBOX XT([1, 1],[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), + # 'TBOXINT XT([1, 2),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), # (1.5, datetime(2019, 9, 1), - # 'TBOX XT([1.5, 1.5],[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), + # 'TBOXFLOAT XT([1.5, 1.5],[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), # (intrange(1, 2, True, True), datetime(2019, 9, 1), - # 'TBOX XT([1, 2],[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), + # 'TBOXINT XT([1, 3),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), # (floatrange(1.5, 2.5, True, True), datetime(2019, 9, 1), - # 'TBOX XT([1.5, 2.5],[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), + # 'TBOXFLOAT XT([1.5, 2.5],[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), # (1, Period('[2019-09-01, 2019-09-02]'), - # 'TBOX XT([1, 1],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), + # 'TBOXINT XT([1, 3),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), # (1.5, Period('[2019-09-01, 2019-09-02]'), - # 'TBOX XT([1.5, 1.5],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), + # 'TBOXFLOAT XT([1.5, 1.5],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), # (intrange(1, 2, True, True), Period('[2019-09-01, 2019-09-02]'), - # 'TBOX XT([1, 2],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), + # 'TBOXINT XT([1, 3),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), # (floatrange(1.5, 2.5, True, True), Period('[2019-09-01, 2019-09-02]'), - # 'TBOX XT([1.5, 2.5],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), + # 'TBOXFLOAT XT([1.5, 2.5],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), # ], # ids=['int-Timestamp', 'float-Timestamp', 'intrange-Timestamp', 'floatrange-Timestamp', # 'int-Period', 'float-Period', 'intrange-Period', 'floatrange-Period',] @@ -133,19 +134,20 @@ def test_from_value_constructor(self, value, expected): @pytest.mark.parametrize( 'tnumber, expected', [ - (TIntInst('1@2019-09-01'), 'TBOX XT([1, 1],[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), - (TFloatInst('1.5@2019-09-01'), 'TBOX XT([1.5, 1.5],[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), - (TIntSeq('{1@2019-09-01,2@2019-09-02}'), 'TBOX XT([1, 2],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), - (TFloatSeq('{1.5@2019-09-01,2.5@2019-09-02}'), 'TBOX XT([1.5, 2.5],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), - (TIntSeq('(1@2019-09-01,2@2019-09-02]'), 'TBOX XT([1, 2],(2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), - (TFloatSeq('[1.5@2019-09-01,2.5@2019-09-02)'), 'TBOX XT([1.5, 2.5),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00))'), + (TIntInst('1@2019-09-01'), 'TBOXINT XT([1, 2),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), + (TIntSeq('{1@2019-09-01,2@2019-09-02}'), 'TBOXINT XT([1, 3),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), + (TIntSeq('(1@2019-09-01,2@2019-09-02]'), 'TBOXINT XT([1, 3),(2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), (TIntSeqSet('{(1@2019-09-01,2@2019-09-02],(1@2019-09-03,2@2019-09-05]}'), - 'TBOX XT([1, 2],(2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])'), + 'TBOXINT XT([1, 3),(2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])'), + + (TFloatInst('1.5@2019-09-01'), 'TBOXFLOAT XT([1.5, 1.5],[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), + (TFloatSeq('{1.5@2019-09-01,2.5@2019-09-02}'), 'TBOXFLOAT XT([1.5, 2.5],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), + (TFloatSeq('[1.5@2019-09-01,2.5@2019-09-02)'), 'TBOXFLOAT XT([1.5, 2.5),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00))'), (TFloatSeqSet('{[1.5@2019-09-01,2.5@2019-09-02),[1.5@2019-09-03,1.5@2019-09-05)}'), - 'TBOX XT([1.5, 2.5),[2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00))'), + 'TBOXFLOAT XT([1.5, 2.5),[2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00))'), ], - ids=['TInt Instant', 'TFloat Instant', 'TInt Discrete Sequence', 'TFloat Discrete Sequence', - 'TInt Sequence', 'TFloat Sequence', 'TInt Sequence Set', 'TFloat Sequence Set'] + ids=['TInt Instant', 'TInt Discrete Sequence', 'TInt Sequence', 'TInt Sequence Set', + 'TFloat Instant', 'TFloat Discrete Sequence', 'TFloat Sequence', 'TFloat Sequence Set'] ) def test_from_tnumber_constructor(self, tnumber, expected): tb = TBox.from_tnumber(tnumber) @@ -154,8 +156,8 @@ def test_from_tnumber_constructor(self, tnumber, expected): @pytest.mark.parametrize( 'tbox', - [tbx, tbt, tbxt], - ids=['TBox X', 'TBox T', 'TBox XT'] + [tbfx, tbt, tbfxt], + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_from_as_constructor(self, tbox): assert tbox == tbox.from_wkb(tbox.as_wkb()) @@ -163,8 +165,8 @@ def test_from_as_constructor(self, tbox): @pytest.mark.parametrize( 'tbox', - [tbx, tbt, tbxt], - ids=['TBox X', 'TBox T', 'TBox XT'] + [tbfx, tbt, tbfxt], + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_copy_constructor(self, tbox): other = copy(tbox) @@ -173,18 +175,18 @@ def test_copy_constructor(self, tbox): class TestTBoxOutputs(TestTBox): - tbx = TBox('TBOX X([1,2])') + tbfx = TBox('TBOXFLOAT X([1,2])') tbt = TBox('TBOX T([2019-09-01,2019-09-02])') - tbxt = TBox('TBOX XT([1,2],[2019-09-01,2019-09-02])') + tbfxt = TBox('TBOXFLOAT XT([1,2],[2019-09-01,2019-09-02])') @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, 'TBOX X([1, 2])'), + (tbfx, 'TBOXFLOAT X([1, 2])'), (tbt, 'TBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), - (tbxt, 'TBOX XT([1, 2],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), + (tbfxt, 'TBOXFLOAT XT([1, 2],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_str(self, tbox, expected): assert str(tbox) == expected @@ -192,11 +194,11 @@ def test_str(self, tbox, expected): @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, 'TBox(TBOX X([1, 2]))'), + (tbfx, 'TBox(TBOXFLOAT X([1, 2]))'), (tbt, 'TBox(TBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00]))'), - (tbxt, 'TBox(TBOX XT([1, 2],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00]))'), + (tbfxt, 'TBox(TBOXFLOAT XT([1, 2],[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00]))'), ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_repr(self, tbox, expected): assert repr(tbox) == expected @@ -204,11 +206,11 @@ def test_repr(self, tbox, expected): @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, '0101070003000000000000F03F0000000000000040'), + (tbfx, '0101070003000000000000F03F0000000000000040'), (tbt, '010221000300A01E4E713402000000F66B85340200'), - (tbxt, '010321000300A01E4E713402000000F66B85340200070003000000000000F03F0000000000000040'), + (tbfxt, '010321000300A01E4E713402000000F66B85340200070003000000000000F03F0000000000000040'), ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_as_hexwkb(self, tbox, expected): assert tbox.as_hexwkb() == expected @@ -216,10 +218,10 @@ def test_as_hexwkb(self, tbox, expected): @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, floatrange(1.0, 2.0, True, True)), - (tbxt, floatrange(1.0, 2.0, True, True)), + (tbfx, floatrange(1.0, 2.0, True, True)), + (tbfxt, floatrange(1.0, 2.0, True, True)), ], - ids=['TBox X', 'TBox XT'] + ids=['TBoxFloat X', 'TBoxFloat XT'] ) def test_to_floatrange(self, tbox, expected): tb = tbox.to_floatrange() @@ -230,9 +232,9 @@ def test_to_floatrange(self, tbox, expected): 'tbox, expected', [ (tbt, Period('[2019-09-01, 2019-09-02]')), - (tbxt, Period('[2019-09-01, 2019-09-02]')), + (tbfxt, Period('[2019-09-01, 2019-09-02]')), ], - ids=['TBox X', 'TBox XT'] + ids=['TBoxFloat X', 'TBoxFloat XT'] ) def test_to_period(self, tbox, expected): tb = tbox.to_period() @@ -241,18 +243,18 @@ def test_to_period(self, tbox, expected): class TestTBoxAccessors(TestTBox): - tbx = TBox('TBox X([1,2])') - tbt = TBox('TBox T([2019-09-01,2019-09-02])') - tbxt = TBox('TBox XT([1,2],[2019-09-01,2019-09-02])') + tbfx = TBox('TBOXFLOAT X([1,2])') + tbt = TBox('TBOX T([2019-09-01,2019-09-02])') + tbfxt = TBox('TBOXFLOAT XT([1,2],[2019-09-01,2019-09-02])') @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, True), + (tbfx, True), (tbt, False), - (tbxt, True) + (tbfxt, True) ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_has_x(self, tbox, expected): assert tbox.has_x() == expected @@ -260,11 +262,11 @@ def test_has_x(self, tbox, expected): @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, False), + (tbfx, False), (tbt, True), - (tbxt, True) + (tbfxt, True) ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_has_t(self, tbox, expected): assert tbox.has_t() == expected @@ -272,11 +274,11 @@ def test_has_t(self, tbox, expected): @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, 1), + (tbfx, 1), (tbt, None), - (tbxt, 1) + (tbfxt, 1) ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_xmin(self, tbox, expected): assert tbox.xmin() == expected @@ -284,11 +286,11 @@ def test_xmin(self, tbox, expected): @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, True), + (tbfx, True), (tbt, None), - (tbxt, True) + (tbfxt, True) ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_xmin_xmax_inc(self, tbox, expected): assert tbox.xmin_inc() == expected @@ -297,11 +299,11 @@ def test_xmin_xmax_inc(self, tbox, expected): @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, 2), + (tbfx, 2), (tbt, None), - (tbxt, 2) + (tbfxt, 2) ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_xmax(self, tbox, expected): assert tbox.xmax() == expected @@ -309,11 +311,11 @@ def test_xmax(self, tbox, expected): @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, None), + (tbfx, None), (tbt, datetime(year=2019, month=9, day=1, tzinfo=timezone.utc)), - (tbxt, datetime(year=2019, month=9, day=1, tzinfo=timezone.utc)) + (tbfxt, datetime(year=2019, month=9, day=1, tzinfo=timezone.utc)) ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_tmin(self, tbox, expected): assert tbox.tmin() == expected @@ -321,11 +323,11 @@ def test_tmin(self, tbox, expected): @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, None), + (tbfx, None), (tbt, True), - (tbxt, True) + (tbfxt, True) ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_tmin_tmax_inc(self, tbox, expected): assert tbox.tmin_inc() == expected @@ -334,27 +336,28 @@ def test_tmin_tmax_inc(self, tbox, expected): @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, None), + (tbfx, None), (tbt, datetime(year=2019, month=9, day=2, tzinfo=timezone.utc)), - (tbxt, datetime(year=2019, month=9, day=2, tzinfo=timezone.utc)) + (tbfxt, datetime(year=2019, month=9, day=2, tzinfo=timezone.utc)) ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_tmax(self, tbox, expected): assert tbox.tmax() == expected + class TestTBoxTransformations(TestTBox): - tbx = TBox('TBox X([1,2])') - tbt = TBox('TBox T([2019-09-01,2019-09-02])') - tbxt = TBox('TBox XT([1,2],[2019-09-01,2019-09-02])') + tbfx = TBox('TBOXFLOAT X([1,2])') + tbt = TBox('TBOX T([2019-09-01,2019-09-02])') + tbfxt = TBox('TBOXFLOAT XT([1,2],[2019-09-01,2019-09-02])') @pytest.mark.parametrize( 'tbox, expected', [ - (tbx, TBox('TBOX X([0, 3])')), - (tbxt, TBox('TBOX XT([0,3],[2019-09-01, 2019-09-02])')), + (tbfx, TBox('TBOXFLOAT X([0, 3])')), + (tbfxt, TBox('TBOXFLOAT XT([0,3],[2019-09-01, 2019-09-02])')), ], - ids=['TBox X', 'TBox XT'] + ids=['TBoxFloat X', 'TBoxFloat XT'] ) def test_expand_float(self, tbox, expected): tb = tbox.expand(1) @@ -365,18 +368,18 @@ def test_expand_float(self, tbox, expected): 'tbox, expected', [ (tbt, TBox('TBOX T([2019-08-31, 2019-09-03])')), - (tbxt, TBox('TBOX XT([1,2],[2019-08-31, 2019-09-03])')), + (tbfxt, TBox('TBOXFLOAT XT([1,2],[2019-08-31, 2019-09-03])')), ], - ids=['TBox T', 'TBox XT'] + ids=['TBox T', 'TBoxFloat XT'] ) def test_expand_time(self, tbox, expected): tb = tbox.expand(timedelta(days=1)) assert isinstance(tb, TBox) assert tb == expected - ###################################### - # THIS TEST DOES NOT WORK CORRECTLY - ###################################### + ##################################### + ## THIS TEST DOES NOT WORK CORRECTLY + ##################################### @pytest.mark.parametrize( 'tbox, delta, expected', [(tbt, timedelta(days=4), @@ -393,9 +396,9 @@ def test_expand_time(self, tbox, expected): def test_shift(self, tbox, delta, expected): assert tbox.shift(delta) == expected - ###################################### - # THIS TEST DOES NOT WORK CORRECTLY - ###################################### + ##################################### + ## THIS TEST DOES NOT WORK CORRECTLY + ##################################### @pytest.mark.parametrize( 'tbox, delta, expected', [(tbt, timedelta(days=4), @@ -408,9 +411,9 @@ def test_shift(self, tbox, delta, expected): def test_tscale(self, tbox, delta, expected): assert tbox.tscale(delta) == expected - ###################################### - # THIS TEST DOES NOT WORK CORRECTLY - ###################################### + ##################################### + ## THIS TEST DOES NOT WORK CORRECTLY + ##################################### def test_shift_tscale(self): assert self.tbt.shift_tscale(timedelta(days=4), timedelta(hours=4)) == \ TBox('TBOX T([2019-09-01,2019-09-02])') @@ -418,34 +421,34 @@ def test_shift_tscale(self): @pytest.mark.parametrize( 'tbox, expected', [ - (TBox('TBOX X([1.123456789,2.123456789])'), - TBox('TBOX X([1.12,2.12])')), - (TBox('TBOX XT([1.123456789,2.123456789],[2019-09-01, 2019-09-02])'), - TBox('TBOX XT([1.12,2.12],[2019-09-01, 2019-09-03])')), + (TBox('TBOXFLOAT X([1.123456789,2.123456789])'), + TBox('TBOXFLOAT X([1.12,2.12])')), + (TBox('TBOXFLOAT XT([1.123456789,2.123456789],[2019-09-01, 2019-09-02])'), + TBox('TBOXFLOAT XT([1.12,2.12],[2019-09-01, 2019-09-03])')), ], - ids=['TBox X', 'TBox XT'] + ids=['TBoxFloat X', 'TBoxFloat XT'] ) def test_round(self, tbox, expected): assert tbox.round(maxdd=2) class TestTBoxTopologicalFunctions(TestTBox): - tbx = TBox('TBOX X([1,2])') + tbfx = TBox('TBOXFLOAT X([1,2])') tbt = TBox('TBOX T([2019-09-01,2019-09-02])') - tbxt = TBox('TBOX XT([1,2],[2019-09-01,2019-09-02])') + tbfxt = TBox('TBOXFLOAT XT([1,2],[2019-09-01,2019-09-02])') @pytest.mark.parametrize( 'tbox, argument, expected', [ - (tbx, TBox('TBOX X([1,3])'), False), - (tbx, TBox('TBOX X((2,3])'), True), + (tbfx, TBox('TBOXFLOAT X([1,3])'), False), + (tbfx, TBox('TBOXFLOAT X((2,3])'), True), (tbt, TBox('TBOX T([2019-09-01,2019-09-03])'), False), (tbt, TBox('TBOX T((2019-09-02,2019-09-03])'), True), - (tbxt, TBox('TBOX XT([1,3],[2019-09-01,2019-09-03])'), False), - (tbxt, TBox('TBOX XT((2,3],[2019-09-02,2019-09-03])'), True), + (tbfxt, TBox('TBOXFLOAT XT([1,3],[2019-09-01,2019-09-03])'), False), + (tbfxt, TBox('TBOXFLOAT XT((2,3],[2019-09-02,2019-09-03])'), True), ], - ids=['TBox X False', 'TBox X True', 'TBox T False', 'TBox T True', - 'TBox XT False', 'TBox XT True'] + ids=['TBoxFloat X False', 'TBoxFloat X True', 'TBox T False', 'TBox T True', + 'TBoxFloat XT False', 'TBoxFloat XT True'] ) def test_is_adjacent(self, tbox, argument, expected): assert tbox.is_adjacent(argument) == expected @@ -453,15 +456,15 @@ def test_is_adjacent(self, tbox, argument, expected): @pytest.mark.parametrize( 'tbox, argument, expected', [ - (tbx, TBox('TBOX X([2,3])'), False), - (tbx, TBox('TBOX X([1,3])'), True), + (tbfx, TBox('TBOXFLOAT X([2,3])'), False), + (tbfx, TBox('TBOXFLOAT X([1,3])'), True), (tbt, TBox('TBOX T([2019-09-02,2019-09-03])'), False), (tbt, TBox('TBOX T([2019-09-01,2019-09-03])'), True), - (tbxt, TBox('TBOX XT([2,3],[2019-09-02,2019-09-03])'), False), - (tbxt, TBox('TBOX XT([1,3],[2019-09-01,2019-09-03])'), True), + (tbfxt, TBox('TBOXFLOAT XT([2,3],[2019-09-02,2019-09-03])'), False), + (tbfxt, TBox('TBOXFLOAT XT([1,3],[2019-09-01,2019-09-03])'), True), ], - ids=['TBox X False', 'TBox X True', 'TBox T False', 'TBox T True', - 'TBox XT False', 'TBox XT True'] + ids=['TBoxFloat X False', 'TBoxFloat X True', 'TBox T False', 'TBox T True', + 'TBoxFloat XT False', 'TBoxFloat XT True'] ) def test_is_contained_in_contains(self, tbox, argument, expected): assert tbox.is_contained_in(argument) == expected @@ -470,15 +473,15 @@ def test_is_contained_in_contains(self, tbox, argument, expected): @pytest.mark.parametrize( 'tbox, argument, expected', [ - (tbx, TBox('TBOX X([3,3])'), False), - (tbx, TBox('TBOX X([1,3])'), True), + (tbfx, TBox('TBOXFLOAT X([3,3])'), False), + (tbfx, TBox('TBOXFLOAT X([1,3])'), True), (tbt, TBox('TBOX T([2019-09-03,2019-09-03])'), False), (tbt, TBox('TBOX T([2019-09-01,2019-09-03])'), True), - (tbxt, TBox('TBOX XT([3,3],[2019-09-02,2019-09-03])'), False), - (tbxt, TBox('TBOX XT([1,3],[2019-09-01,2019-09-03])'), True), + (tbfxt, TBox('TBOXFLOAT XT([3,3],[2019-09-02,2019-09-03])'), False), + (tbfxt, TBox('TBOXFLOAT XT([1,3],[2019-09-01,2019-09-03])'), True), ], - ids=['TBox X False', 'TBox X True', 'TBox T False', 'TBox T True', - 'TBox XT False', 'TBox XT True'] + ids=['TBoxFloat X False', 'TBoxFloat X True', 'TBox T False', 'TBox T True', + 'TBoxFloat XT False', 'TBoxFloat XT True'] ) def test_overlaps(self, tbox, argument, expected): assert tbox.overlaps(argument) == expected @@ -486,34 +489,34 @@ def test_overlaps(self, tbox, argument, expected): @pytest.mark.parametrize( 'tbox, argument, expected', [ - (tbx, TBox('TBOX X([3,3])'), False), - (tbx, TBox('TBOX X([1,2])'), True), + (tbfx, TBox('TBOXFLOAT X([3,3])'), False), + (tbfx, TBox('TBOXFLOAT X([1,2])'), True), (tbt, TBox('TBOX T([2019-09-03,2019-09-03])'), False), (tbt, TBox('TBOX T([2019-09-01,2019-09-02])'), True), - (tbxt, TBox('TBOX X([3,3])'), False), - (tbxt, TBox('TBOX X([1,2])'), True), + (tbfxt, TBox('TBOXFLOAT X([3,3])'), False), + (tbfxt, TBox('TBOXFLOAT X([1,2])'), True), ], - ids=['TBox X False', 'TBox X True', 'TBox T False', 'TBox T True', - 'TBox XT False', 'TBox XT True'] + ids=['TBoxFloat X False', 'TBoxFloat X True', 'TBox T False', 'TBox T True', + 'TBoxFloat XT False', 'TBoxFloat XT True'] ) def test_is_same(self, tbox, argument, expected): assert tbox.is_same(argument) == expected class TestTBoxPositionFunctions(TestTBox): - tbx = TBox('TBOX X([1,2])') + tbfx = TBox('TBOXFLOAT X([1,2])') tbt = TBox('TBOX T([2019-09-01,2019-09-02])') - tbxt = TBox('TBOX XT([1,2],[2019-09-01,2019-09-02])') + tbfxt = TBox('TBOXFLOAT XT([1,2],[2019-09-01,2019-09-02])') @pytest.mark.parametrize( 'tbox, argument, expected', [ - (tbx, TBox('TBOX X([1,3])'), False), - (tbx, TBox('TBOX X([3,4])'), True), - (tbxt, TBox('TBOX XT([1,3],[2019-09-01,2019-09-03])'), False), - (tbxt, TBox('TBOX XT([3,4],[2019-09-02,2019-09-03])'), True), + (tbfx, TBox('TBOXFLOAT X([1,3])'), False), + (tbfx, TBox('TBOXFLOAT X([3,4])'), True), + (tbfxt, TBox('TBOXFLOAT XT([1,3],[2019-09-01,2019-09-03])'), False), + (tbfxt, TBox('TBOXFLOAT XT([3,4],[2019-09-02,2019-09-03])'), True), ], - ids=['TBox X False', 'TBox X True', 'TBox XT False', 'TBox XT True'] + ids=['TBoxFloat X False', 'TBoxFloat X True', 'TBoxFloat XT False', 'TBoxFloat XT True'] ) def test_is_left_right(self, tbox, argument, expected): assert tbox.is_left(argument) == expected @@ -522,12 +525,12 @@ def test_is_left_right(self, tbox, argument, expected): @pytest.mark.parametrize( 'tbox, argument, expected', [ - (tbx, TBox('TBOX X([1,1])'), False), - (tbx, TBox('TBOX X([3,4])'), True), - (tbxt, TBox('TBOX XT([1,1],[2019-09-01,2019-09-03])'), False), - (tbxt, TBox('TBOX XT([3,4],[2019-09-02,2019-09-03])'), True), + (tbfx, TBox('TBOXFLOAT X([1,1])'), False), + (tbfx, TBox('TBOXFLOAT X([3,4])'), True), + (tbfxt, TBox('TBOXFLOAT XT([1,1],[2019-09-01,2019-09-03])'), False), + (tbfxt, TBox('TBOXFLOAT XT([3,4],[2019-09-02,2019-09-03])'), True), ], - ids=['TBox X False', 'TBox X True', 'TBox XT False', 'TBox XT True'] + ids=['TBoxFloat X False', 'TBoxFloat X True', 'TBoxFloat XT False', 'TBoxFloat XT True'] ) def test_is_over_or_left(self, tbox, argument, expected): assert tbox.is_over_or_left(argument) == expected @@ -535,12 +538,12 @@ def test_is_over_or_left(self, tbox, argument, expected): @pytest.mark.parametrize( 'tbox, argument, expected', [ - (tbx, TBox('TBOX X([0,1])'), False), - (tbx, TBox('TBOX X([3,4])'), True), - (tbxt, TBox('TBOX XT([0,1],[2019-09-01,2019-09-03])'), False), - (tbxt, TBox('TBOX XT([3,4],[2019-09-02,2019-09-03])'), True), + (tbfx, TBox('TBOXFLOAT X([0,1])'), False), + (tbfx, TBox('TBOXFLOAT X([3,4])'), True), + (tbfxt, TBox('TBOXFLOAT XT([0,1],[2019-09-01,2019-09-03])'), False), + (tbfxt, TBox('TBOXFLOAT XT([3,4],[2019-09-02,2019-09-03])'), True), ], - ids=['TBox X False', 'TBox X True', 'TBox XT False', 'TBox XT True'] + ids=['TBoxFloat X False', 'TBoxFloat X True', 'TBoxFloat XT False', 'TBoxFloat XT True'] ) def test_is_over_or_right(self, tbox, argument, expected): assert argument.is_over_or_right(tbox) == expected @@ -550,10 +553,10 @@ def test_is_over_or_right(self, tbox, argument, expected): [ (tbt, TBox('TBOX T([2019-09-01,2019-09-03])'), False), (tbt, TBox('TBOX T([2019-09-03,2019-09-03])'), True), - (tbxt, TBox('TBOX XT([1,3],[2019-09-01,2019-09-03])'), False), - (tbxt, TBox('TBOX XT([3,4],[2019-09-03,2019-09-03])'), True), + (tbfxt, TBox('TBOXFLOAT XT([1,3],[2019-09-01,2019-09-03])'), False), + (tbfxt, TBox('TBOXFLOAT XT([3,4],[2019-09-03,2019-09-03])'), True), ], - ids=['TBox T False', 'TBox T True', 'TBox XT False', 'TBox XT True'] + ids=['TBox T False', 'TBox T True', 'TBoxFloat XT False', 'TBoxFloat XT True'] ) def test_is_before_after(self, tbox, argument, expected): assert tbox.is_before(argument) == expected @@ -564,10 +567,10 @@ def test_is_before_after(self, tbox, argument, expected): [ (tbt, TBox('TBOX T([2019-09-01,2019-09-01])'), False), (tbt, TBox('TBOX T([2019-09-03,2019-09-03])'), True), - (tbxt, TBox('TBOX XT([1,3],[2019-09-01,2019-09-01])'), False), - (tbxt, TBox('TBOX XT([3,4],[2019-09-03,2019-09-03])'), True), + (tbfxt, TBox('TBOXFLOAT XT([1,3],[2019-09-01,2019-09-01])'), False), + (tbfxt, TBox('TBOXFLOAT XT([3,4],[2019-09-03,2019-09-03])'), True), ], - ids=['TBox T False', 'TBox T True', 'TBox XT False', 'TBox XT True'] + ids=['TBox T False', 'TBox T True', 'TBoxFloat XT False', 'TBoxFloat XT True'] ) def test_is_over_or_before(self, tbox, argument, expected): assert tbox.is_over_or_before(argument) == expected @@ -577,31 +580,31 @@ def test_is_over_or_before(self, tbox, argument, expected): [ (tbt, TBox('TBOX T([2019-09-03,2019-09-03])'), False), (tbt, TBox('TBOX T([2019-09-01,2019-09-03])'), True), - (tbxt, TBox('TBOX XT([1,3],[2019-09-02,2019-09-03])'), False), - (tbxt, TBox('TBOX XT([3,4],[2019-09-01,2019-09-03])'), True), + (tbfxt, TBox('TBOXFLOAT XT([1,3],[2019-09-02,2019-09-03])'), False), + (tbfxt, TBox('TBOXFLOAT XT([3,4],[2019-09-01,2019-09-03])'), True), ], - ids=['TBox T False', 'TBox T True', 'TBox XT False', 'TBox XT True'] + ids=['TBox T False', 'TBox T True', 'TBoxFloat XT False', 'TBoxFloat XT True'] ) def test_is_over_or_after(self, tbox, argument, expected): assert tbox.is_over_or_after(argument) == expected class TestTBoxSetFunctions(TestTBox): - tbx1 = TBox('TBox X([1,2])') - tbt1 = TBox('TBox T([2019-09-01,2019-09-02])') - tbxt1 = TBox('TBox XT([1,2],[2019-09-01,2019-09-02])') - tbx2 = TBox('TBox X([2,3])') - tbt2 = TBox('TBox T([2019-09-02,2019-09-03])') - tbxt2 = TBox('TBox XT([2,3],[2019-09-02,2019-09-03])') + tbx1 = TBox('TBOXFLOAT X([1,2])') + tbt1 = TBox('TBOX T([2019-09-01,2019-09-02])') + tbxt1 = TBox('TBOXFLOAT XT([1,2],[2019-09-01,2019-09-02])') + tbx2 = TBox('TBOXFLOAT X([2,3])') + tbt2 = TBox('TBOX T([2019-09-02,2019-09-03])') + tbxt2 = TBox('TBOXFLOAT XT([2,3],[2019-09-02,2019-09-03])') @pytest.mark.parametrize( 'tbox1, tbox2, expected', [ - (tbx1, tbx2, TBox('TBox X([1,3])')), - (tbt1, tbt2, TBox('TBox T([2019-09-01,2019-09-03])')), - (tbxt1, tbxt2, TBox('TBox XT([1,3],[2019-09-01,2019-09-03])')) + (tbx1, tbx2, TBox('TBOXFLOAT X([1,3])')), + (tbt1, tbt2, TBox('TBOXFLOAT T([2019-09-01,2019-09-03])')), + (tbxt1, tbxt2, TBox('TBOXFLOAT XT([1,3],[2019-09-01,2019-09-03])')) ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBox T', 'TBoxFloat XT'] ) def test_union(self, tbox1, tbox2, expected): assert tbox1.union(tbox2) == expected @@ -610,11 +613,11 @@ def test_union(self, tbox1, tbox2, expected): @pytest.mark.parametrize( 'tbox1, tbox2, expected', [ - (tbx1, tbx2, TBox('TBox X([2,2])')), - (tbt1, tbt2, TBox('TBox T([2019-09-02,2019-09-02])')), - (tbxt1, tbxt2, TBox('TBox XT([2,2],[2019-09-02,2019-09-02])')) + (tbx1, tbx2, TBox('TBOXFLOAT X([2,2])')), + (tbt1, tbt2, TBox('TBOX T([2019-09-02,2019-09-02])')), + (tbxt1, tbxt2, TBox('TBOXFLOAT XT([2,2],[2019-09-02,2019-09-02])')) ], - ids=['TBox X', 'TBox T', 'TBox XT'] + ids=['TBoxFloat X', 'TBpx T', 'TBoxFloat XT'] ) def test_intersection(self, tbox1, tbox2, expected): assert tbox1.intersection(tbox2) == expected @@ -622,43 +625,43 @@ def test_intersection(self, tbox1, tbox2, expected): class TestTBoxDistanceFunctions(TestTBox): - tbx = TBox('TBOX X([1,2])') + tbfx = TBox('TBOXFLOAT X([1,2])') tbt = TBox('TBOX T([2019-09-01,2019-09-02])') - tbxt = TBox('TBOX XT([1,2],[2019-09-01,2019-09-02])') + tbfxt = TBox('TBOXFLOAT XT([1,2],[2019-09-01,2019-09-02])') @pytest.mark.parametrize( 'tbox, argument, expected', [ - (tbx, TBox('TBOX X([1,3])'), 0), - (tbx, TBox('TBOX X([3,4])'), 1), - (tbxt, TBox('TBOX XT([1,3],[2019-09-01,2019-09-03])'), 0), - (tbxt, TBox('TBOX XT([3,4],[2019-09-01,2019-09-03])'), 1), + (tbfx, TBox('TBOXFLOAT X([1,3])'), 0), + (tbfx, TBox('TBOXFLOAT X([3,4])'), 1), + (tbfxt, TBox('TBOXFLOAT XT([1,3],[2019-09-01,2019-09-03])'), 0), + (tbfxt, TBox('TBOXFLOAT XT([3,4],[2019-09-01,2019-09-03])'), 1), ], - ids=['TBox X Intersection', 'TBox X Distance', - 'TBox XT Intersection', 'TBox XT Distance'] + ids=['TBoxFloat X Intersection', 'TBoxFloat X Distance', + 'TBoxFloat XT Intersection', 'TBoxFloat XT Distance'] ) def test_nearest_approach_distance(self, tbox, argument, expected): assert tbox.nearest_approach_distance(argument) == expected class TestTBoxComparisons(TestTBox): - tbxt = TBox('TBOX XT([1,2],[2019-09-01,2019-09-02])') - other = TBox('TBOX XT([3,4],[2019-09-03,2019-09-04])') + tbfxt = TBox('TBOXFLOAT XT([1,2],[2019-09-01,2019-09-02])') + other = TBox('TBOXFLOAT XT([3,4],[2019-09-03,2019-09-04])') def test_eq(self): - _ = self.tbxt == self.other + _ = self.tbfxt == self.other def test_ne(self): - _ = self.tbxt != self.other + _ = self.tbfxt != self.other def test_lt(self): - _ = self.tbxt < self.other + _ = self.tbfxt < self.other def test_le(self): - _ = self.tbxt <= self.other + _ = self.tbfxt <= self.other def test_gt(self): - _ = self.tbxt > self.other + _ = self.tbfxt > self.other def test_ge(self): - _ = self.tbxt >= self.other + _ = self.tbfxt >= self.other diff --git a/pymeos/tests/main/tbool_test.py b/pymeos/tests/main/tbool_test.py index cb01946a..dbff67da 100644 --- a/pymeos/tests/main/tbool_test.py +++ b/pymeos/tests/main/tbool_test.py @@ -330,6 +330,19 @@ class TestTBoolAccessors(TestTBool): tbs = TBoolSeq('[True@2019-09-01, False@2019-09-02]') tbss = TBoolSeqSet('{[True@2019-09-01, False@2019-09-02],[True@2019-09-03, True@2019-09-05]}') + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tbi, Period('[2019-09-01, 2019-09-01]')), + (tbds, Period('[2019-09-01, 2019-09-02]')), + (tbs, Period('[2019-09-01, 2019-09-02]')), + (tbss, Period('[2019-09-01, 2019-09-05]')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_bounding_box(self, temporal, expected): + assert temporal.bounding_box() == expected + @pytest.mark.parametrize( 'temporal, expected', [ @@ -542,27 +555,27 @@ def test_end_instant(self, temporal, expected): 'temporal, expected', [ (tbi, tbi), - (tbds, tbi), - (tbs, tbi), - (tbss, tbi), + (tbds, TBoolInst('False@2019-09-02')), + (tbs, TBoolInst('False@2019-09-02')), + (tbss, TBoolInst('False@2019-09-02')), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_max_instant(self, temporal, expected): - assert temporal.max_instant() == expected + def test_min_instant(self, temporal, expected): + assert temporal.min_instant() == expected @pytest.mark.parametrize( 'temporal, expected', [ (tbi, tbi), - (tbds, TBoolInst('False@2019-09-02')), - (tbs, TBoolInst('False@2019-09-02')), - (tbss, TBoolInst('False@2019-09-02')), + (tbds, tbi), + (tbs, tbi), + (tbss, tbi), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_min_instant(self, temporal, expected): - assert temporal.min_instant() == expected + def test_max_instant(self, temporal, expected): + assert temporal.max_instant() == expected @pytest.mark.parametrize( 'temporal, n, expected', @@ -676,18 +689,6 @@ def test_timestamps(self, temporal, expected): def test_segments(self, temporal, expected): assert temporal.segments() == expected - @pytest.mark.parametrize( - 'temporal, expected', - [ - (tbds, True), - (tbs, True), - ], - ids=['Discrete Sequence', 'Sequence'] - ) - def test_lower_upper_inc(self, temporal, expected): - assert temporal.lower_inc() == expected - assert temporal.upper_inc() == expected - @pytest.mark.parametrize( 'temporal, expected', [ @@ -701,6 +702,33 @@ def test_lower_upper_inc(self, temporal, expected): def test_hash(self, temporal, expected): assert hash(temporal) == expected + def test_value_timestamp(self): + assert self.tbi.value() == True + assert self.tbi.timestamp() == datetime(year=2019, month=9, day=1, tzinfo=timezone.utc) + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tbds, True), + (tbs, True), + ], + ids=['Discrete Sequence', 'Sequence'] + ) + def test_lower_upper_inc(self, temporal, expected): + assert temporal.lower_inc() == expected + assert temporal.upper_inc() == expected + + def test_sequenceset_sequence_functions(self): + tbss1 =TBoolSeqSet('{[True@2019-09-01, False@2019-09-02],' + '[True@2019-09-03, True@2019-09-05], [True@2019-09-06]}') + assert tbss1.num_sequences() == 3 + assert tbss1.start_sequence() == TBoolSeq('[True@2019-09-01, False@2019-09-02]') + assert tbss1.end_sequence() == TBoolSeq('[True@2019-09-06]') + assert tbss1.sequence_n(1) == TBoolSeq('[True@2019-09-03, True@2019-09-05]') + assert tbss1.sequences() == [TBoolSeq('[True@2019-09-01, False@2019-09-02]'), + TBoolSeq('[True@2019-09-03, True@2019-09-05]'), + TBoolSeq('[True@2019-09-06]')] + class TestTBoolTransformations(TestTBool): tbi = TBoolInst('True@2019-09-01') @@ -825,6 +853,29 @@ def test_shift_tscale(self): TBoolSeqSet('{[True@2019-09-05 00:00:00, False@2019-09-05 00:30:00],' '[True@2019-09-05 01:00:00, True@2019-09-05 02:00:00]}') + @pytest.mark.parametrize( + 'tint, delta, expected', + [(tbi, timedelta(days=4), TBoolInst('True@2019-09-01')), + (tbi, timedelta(hours=12), TBoolInst('True@2019-09-01')), + (tbds, timedelta(days=4), TBoolSeq('{True@2019-09-01}')), + (tbds, timedelta(hours=12), TBoolSeq('{True@2019-09-01, False@2019-09-02}')), + (tbs, timedelta(days=4), TBoolSeq('{True@2019-09-01}')), + (tbs, timedelta(hours=12), TBoolSeq('{True@2019-09-01, True@2019-09-01 12:00:00, False@2019-09-02}')), + (tbss, timedelta(days=4), + TBoolSeq('{True@2019-09-01,True@2019-09-05}')), + (tbss, timedelta(hours=12), + TBoolSeq('{True@2019-09-01, True@2019-09-01 12:00:00, False@2019-09-02,' + 'True@2019-09-03, True@2019-09-03 12:00:00, True@2019-09-04, ' + 'True@2019-09-04 12:00:00, True@2019-09-05}')), + ], + ids=['Instant days', 'Instant hours', + 'Discrete Sequence days', 'Discrete Sequence hours', + 'Sequence days', 'Sequence hours', + 'Sequence Set days', 'Sequence Set hours'] + ) + def test_temporal_sample(self, tint, delta, expected): + assert tint.temporal_sample(delta) == expected + class TestTBoolModifications(TestTBool): tbi = TBoolInst('True@2019-09-01') diff --git a/pymeos/tests/main/tfloat_test.py b/pymeos/tests/main/tfloat_test.py index 258f3653..b1417bb3 100644 --- a/pymeos/tests/main/tfloat_test.py +++ b/pymeos/tests/main/tfloat_test.py @@ -30,24 +30,8 @@ class TestTFloatConstructors(TestTFloat): [ (TIntInst('1@2019-09-01'), TFloatInst, TInterpolation.NONE), (TIntSeq('{1@2019-09-01, 2@2019-09-02}'), TFloatSeq, TInterpolation.DISCRETE), - (TIntSeq('[1@2019-09-01, 2@2019-09-02]'), TFloatSeq, TInterpolation.STEPWISE), + (TIntSeq('[1@2019-09-01, 2@2019-09-02]'), TFloatSeq, TInterpolation.LINEAR), (TIntSeqSet('{[1@2019-09-01, 2@2019-09-02],[1@2019-09-03, 1@2019-09-05]}'), - TFloatSeqSet, TInterpolation.STEPWISE) - ], - ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] - ) - def test_from_base_constructor(self, source, type, interpolation): - tf = TFloat.from_base_temporal(1.5, source) - assert isinstance(tf, type) - assert tf.interpolation() == interpolation - - @pytest.mark.parametrize( - 'source, type, interpolation', - [ - (TFloatInst('1@2019-09-01'), TFloatInst, TInterpolation.NONE), - (TFloatSeq('{1@2019-09-01, 2@2019-09-02}'), TFloatSeq, TInterpolation.DISCRETE), - (TFloatSeq('[1@2019-09-01, 2@2019-09-02]'), TFloatSeq, TInterpolation.LINEAR), - (TFloatSeqSet('{[1@2019-09-01, 2@2019-09-02],[1@2019-09-03, 1@2019-09-05]}'), TFloatSeqSet, TInterpolation.LINEAR) ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] @@ -369,6 +353,30 @@ def test_as_mfjson(self, temporal, expected): assert temporal.as_mfjson() == expected +class TestTFloatConversions(TestTFloat): + tfi = TFloatInst('1.5@2019-09-01') + tfds = TFloatSeq('{1.5@2019-09-01, 2.5@2019-09-02}') + tfs = TFloatSeq('[1.5@2019-09-01, 2.5@2019-09-02]') + tfss = TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02],[1.5@2019-09-03, 1.5@2019-09-05]}') + tfsts = TFloatSeq('Interp=Step;[1.5@2019-09-01, 2.5@2019-09-02]') + tfstss = TFloatSeqSet('Interp=Step;{[1.5@2019-09-01, 2.5@2019-09-02],[1.5@2019-09-03, 1.5@2019-09-05]}') + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tfi, TIntInst('1@2019-09-01')), + (tfds, TIntSeq('{1@2019-09-01,2@2019-09-02}')), + (tfsts, TIntSeq('[1@2019-09-01,2@2019-09-02]')), + (tfstss, TIntSeq('{[1@2019-09-01,2@2019-09-02],[1@2019-09-03,1@2019-09-05]}')), + ], + ids=['Instant', 'Discrete Sequence', 'Step Sequence', 'Step Sequence Set'] + ) + def test_to_tint(self, temporal, expected): + temp = temporal.to_tint() + assert isinstance(temp, TInt) + assert temp == expected + + class TestTFloatAccessors(TestTFloat): tfi = TFloatInst('1.5@2019-09-01') tfds = TFloatSeq('{1.5@2019-09-01, 2.5@2019-09-02}') @@ -377,6 +385,19 @@ class TestTFloatAccessors(TestTFloat): tfsts = TFloatSeq('Interp=Step;[1.5@2019-09-01, 2.5@2019-09-02]') tfstss = TFloatSeqSet('Interp=Step;{[1.5@2019-09-01, 2.5@2019-09-02],[1.5@2019-09-03, 1.5@2019-09-05]}') + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tfi, TBox('TBOXFLOAT XT([1.5,1.5],[2019-09-01, 2019-09-01])')), + (tfds, TBox('TBOXFLOAT XT([1.5,2.5],[2019-09-01, 2019-09-02])')), + (tfs, TBox('TBOXFLOAT XT([1.5,2.5],[2019-09-01, 2019-09-02])')), + (tfss, TBox('TBOXFLOAT XT([1.5,2.5],[2019-09-01, 2019-09-05])')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_bounding_box(self, temporal, expected): + assert temporal.bounding_box() == expected + @pytest.mark.parametrize( 'temporal, expected', [ @@ -416,6 +437,32 @@ def test_value_set(self, temporal, expected): def test_values(self, temporal, expected): assert temporal.values() == expected + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tfi, floatrange(1.5, 1.5, True, True)), + (tfds, floatrange(1.5, 2.5, True, True)), + (tfs, floatrange(1.5, 2.5, True, True)), + (tfss, floatrange(1.5, 2.5, True, True)), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_value_range(self, temporal, expected): + assert temporal.value_range() == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tfi, [floatrange(1.5, 1.5, True, True)]), + (tfds, [floatrange(1.5, 1.5, True, True),floatrange(2.5, 2.5, True, True)]), + (tfs, [floatrange(1.5, 2.5, True, True)]), + (tfss, [floatrange(1.5, 2.5, True, True)]), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_value_ranges(self, temporal, expected): + assert temporal.value_ranges() == expected + @pytest.mark.parametrize( 'temporal, expected', [ @@ -589,27 +636,27 @@ def test_end_instant(self, temporal, expected): 'temporal, expected', [ (tfi, tfi), - (tfds, TFloatInst('2.5@2019-09-02')), - (tfs, TFloatInst('2.5@2019-09-02')), - (tfss, TFloatInst('2.5@2019-09-02')), + (tfds, tfi), + (tfs, tfi), + (tfss, tfi), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_max_instant(self, temporal, expected): - assert temporal.max_instant() == expected + def test_min_instant(self, temporal, expected): + assert temporal.min_instant() == expected @pytest.mark.parametrize( 'temporal, expected', [ (tfi, tfi), - (tfds, tfi), - (tfs, tfi), - (tfss, tfi), + (tfds, TFloatInst('2.5@2019-09-02')), + (tfs, TFloatInst('2.5@2019-09-02')), + (tfss, TFloatInst('2.5@2019-09-02')), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_min_instant(self, temporal, expected): - assert temporal.min_instant() == expected + def test_max_instant(self, temporal, expected): + assert temporal.max_instant() == expected @pytest.mark.parametrize( 'temporal, n, expected', @@ -725,6 +772,26 @@ def test_timestamps(self, temporal, expected): def test_segments(self, temporal, expected): assert temporal.segments() == expected + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tfi, 1307112078), + (tfds, 1935376725), + (tfs, 1935376725), + (tfss, 4247071962), + (tfs, 1935376725), + (tfss, 4247071962) + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet', + 'Stepwise Sequence', 'Stepwise SequenceSet'] + ) + def test_hash(self, temporal, expected): + assert hash(temporal) == expected + + def test_value_timestamp(self): + assert self.tfi.value() == 1.5 + assert self.tfi.timestamp() == datetime(year=2019, month=9, day=1, tzinfo=timezone.utc) + @pytest.mark.parametrize( 'temporal, expected', [ @@ -732,40 +799,48 @@ def test_segments(self, temporal, expected): (tfs, True), (tfsts, True), ], - ids=['Discrete Sequence', 'Sequence', 'Stepwise Sequence'] + ids=['Discrete Sequence', 'Sequence', 'Step Sequence'] ) def test_lower_upper_inc(self, temporal, expected): assert temporal.lower_inc() == expected assert temporal.upper_inc() == expected + def test_sequenceset_sequence_functions(self): + tfss1 =TFloatSeqSet('{[1@2019-09-01, 2@2019-09-02],' + '[1@2019-09-03, 1@2019-09-05], [3@2019-09-06]}') + assert tfss1.num_sequences() == 3 + assert tfss1.start_sequence() == TFloatSeq('[1@2019-09-01, 2@2019-09-02]') + assert tfss1.end_sequence() == TFloatSeq('[3@2019-09-06]') + assert tfss1.sequence_n(1) == TFloatSeq('[1@2019-09-03, 1@2019-09-05]') + assert tfss1.sequences() == [TFloatSeq('[1@2019-09-01, 2@2019-09-02]'), + TFloatSeq('[1@2019-09-03, 1@2019-09-05]'), + TFloatSeq('[3@2019-09-06]')] + @pytest.mark.parametrize( 'temporal, expected', [ - (tfi, 1307112078), - (tfds, 1935376725), - (tfs, 1935376725), - (tfss, 4247071962), - (tfs, 1935376725), - (tfss, 4247071962) + (tfi, 0), + (tfds, 0), + (tfs, 172800000000), + (tfss, 432000000000), ], - ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet', - 'Stepwise Sequence', 'Stepwise SequenceSet'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_hash(self, temporal, expected): - assert hash(temporal) == expected + def test_integral(self, temporal, expected): + assert temporal.integral() == expected @pytest.mark.parametrize( 'temporal, expected', [ - (tfi, TBox('TBOX XT([1.5,1.5],[2019-09-01, 2019-09-01])')), - (tfds, TBox('TBOX XT([1.5,2.5],[2019-09-01, 2019-09-02])')), - (tfs, TBox('TBOX XT([1.5,2.5],[2019-09-01, 2019-09-02])')), - (tfss, TBox('TBOX XT([1.5,2.5],[2019-09-01, 2019-09-05])')), + (tfi, 1.5), + (tfds, 2), + (tfs, 2), + (tfss, 1.6667), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_bounding_box(self, temporal, expected): - assert temporal.bounding_box() == expected + def test_time_weighted_average(self, temporal, expected): + assert round(temporal.time_weighted_average(), 4) == expected class TestTFloatTransformations(TestTFloat): @@ -776,6 +851,15 @@ class TestTFloatTransformations(TestTFloat): tfss = TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02],[1.5@2019-09-03, 1.5@2019-09-05]}') tfstss = TFloatSeqSet('Interp=Step;{[1.5@2019-09-01, 2.5@2019-09-02],[1.5@2019-09-03, 1.5@2019-09-05]}') + tfs_d = TFloatSeq('[1.5@2019-09-01]') + tfss_d = TFloatSeqSet('{[1.5@2019-09-01],[2.5@2019-09-03]}') + tfs_s = TFloatSeq('[1.5@2019-09-01, 1.5@2019-09-02]') + tfss_s = TFloatSeqSet('{[1.5@2019-09-01, 1.5@2019-09-02],' + '[2.5@2019-09-03, 2.5@2019-09-05]}') + tfs_l = TFloatSeq('Interp=Step;[1.5@2019-09-01, 2.5@2019-09-02]') + tfss_l = TFloatSeqSet('Interp=Step;{[1.5@2019-09-01, 2.5@2019-09-02],' + '[1.5@2019-09-03, 1.5@2019-09-05]}') + @pytest.mark.parametrize( 'temporal, expected', [ @@ -829,6 +913,44 @@ def test_to_sequenceset(self, temporal, expected): assert isinstance(temp, TFloatSeqSet) assert temp == expected + @pytest.mark.parametrize( + 'temporal, interpolation, expected', + [ + (tfi, TInterpolation.DISCRETE, + TFloatSeq('{1.5@2019-09-01}')), + (tfds, TInterpolation.DISCRETE, tfds), + (tfs_d, TInterpolation.DISCRETE, + TFloatSeq('{1.5@2019-09-01}')), + (tfss_d, TInterpolation.DISCRETE, + TFloatSeq('{1.5@2019-09-01,2.5@2019-09-03}')), + + (tfi, TInterpolation.STEPWISE, + TFloatSeq('Interp=Step;[1.5@2019-09-01]')), + (tfds, TInterpolation.STEPWISE, + TFloatSeqSet('Interp=Step;{[1.5@2019-09-01], [2.5@2019-09-02]}')), + (tfs_s, TInterpolation.STEPWISE, + TFloatSeq('Interp=Step;[1.5@2019-09-01, 1.5@2019-09-02]')), + (tfss_s, TInterpolation.STEPWISE, + TFloatSeqSet('Interp=Step;{[1.5@2019-09-01, 1.5@2019-09-02],' + '[2.5@2019-09-03, 2.5@2019-09-05]}')), + + (tfi, TInterpolation.LINEAR, + TFloatSeq('[1.5@2019-09-01]')), + (tfds, TInterpolation.LINEAR, + TFloatSeqSet('{[1.5@2019-09-01], [2.5@2019-09-02]}')), + (tfs_l, TInterpolation.LINEAR, + TFloatSeqSet('{[1.5@2019-09-01, 1.5@2019-09-02), [2.5@2019-09-02]}')), + (tfss_l, TInterpolation.LINEAR, + TFloatSeqSet('{[1.5@2019-09-01, 1.5@2019-09-02),' + '[2.5@2019-09-02],[1.5@2019-09-03, 1.5@2019-09-05]}')), + ], + ids=['Instant to discrete', 'Discrete Sequence to discrete', 'Sequence to discrete', 'SequenceSet to discrete', + 'Instant to step', 'Discrete Sequence to step', 'Sequence to step', 'SequenceSet to step', + 'Instant to linear', 'Discrete Sequence to linear', 'Sequence to linear', 'SequenceSet to linear'] + ) + def test_set_interpolation(self, temporal, interpolation, expected): + assert temporal.set_interpolation(interpolation) == expected + @pytest.mark.parametrize( 'tfloat, delta, expected', [(tfi, timedelta(days=4), TFloatInst('1.5@2019-09-05')), @@ -894,32 +1016,85 @@ def test_shift_tscale(self): '[1.5@2019-09-05 01:00:00, 1.5@2019-09-05 02:00:00]}') @pytest.mark.parametrize( - 'temporal, expected', - [ - (tfi, TIntInst('1@2019-09-01')), - (tfds, TIntSeq('{1@2019-09-01,2@2019-09-02}')), - (tfsts, TIntSeq('[1@2019-09-01,2@2019-09-02]')), - (tfstss, TIntSeq('{[1@2019-09-01,2@2019-09-02],[1@2019-09-03,1@2019-09-05]}')), - ], - ids=['Instant', 'Discrete Sequence', 'Step Sequence', 'Step Sequence Set'] + 'tfloat, delta, expected', + [(tfi, timedelta(days=4), TFloatInst('1.5@2019-09-01')), + (tfi, timedelta(hours=12), TFloatInst('1.5@2019-09-01')), + (tfds, timedelta(days=4), TFloatSeq('{1.5@2019-09-01}')), + (tfds, timedelta(hours=12), TFloatSeq('{1.5@2019-09-01, 2.5@2019-09-02}')), + (tfs, timedelta(days=4), TFloatSeq('{1.5@2019-09-01}')), + (tfs, timedelta(hours=12), TFloatSeq('{1.5@2019-09-01, 2@2019-09-01 12:00:00, 2.5@2019-09-02}')), + (tfss, timedelta(days=4), + TFloatSeq('{1.5@2019-09-01,1.5@2019-09-05}')), + (tfss, timedelta(hours=12), + TFloatSeq('{1.5@2019-09-01, 2@2019-09-01 12:00:00, 2.5@2019-09-02,' + '1.5@2019-09-03, 1.5@2019-09-03 12:00:00, 1.5@2019-09-04, ' + '1.5@2019-09-04 12:00:00, 1.5@2019-09-05}')), + ], + ids=['Instant days', 'Instant hours', + 'Discrete Sequence days', 'Discrete Sequence hours', + 'Sequence days', 'Sequence hours', + 'Sequence Set days', 'Sequence Set hours'] + ) + def test_temporal_sample(self, tfloat, delta, expected): + assert tfloat.temporal_sample(delta) == expected + + # This function should be corrected in MEOS + # @pytest.mark.parametrize( + # 'tfloat, delta, expected', + # [(tfi, timedelta(days=4), TFloatInst('1.5@2019-09-01')), + # (tfi, timedelta(hours=12), TFloatInst('1.5@2019-09-01')), + # (tfds, timedelta(days=4), TFloatSeq('{2@2019-09-01}')), + # (tfds, timedelta(hours=12), TFloatSeq('{1.5@2019-09-01, 2.5@2019-09-02}')), + # (tfs, timedelta(days=4), TFloatSeq('{2@2019-09-01}')), + # (tfs, timedelta(hours=12), TFloatSeq('{1.5@2019-09-01, 2@2019-09-01 12:00:00, 2.5@2019-09-02}')), + # (tfss, timedelta(days=4), + # TFloatSeq('{1.5@2019-09-01,1.5@2019-09-05}')), + # (tfss, timedelta(hours=12), + # TFloatSeq('{1.5@2019-09-01, 2@2019-09-01 12:00:00, 2.5@2019-09-02,' + # '1.5@2019-09-03, 1.5@2019-09-03 12:00:00, 1.5@2019-09-04, ' + # '1.5@2019-09-04 12:00:00, 1.5@2019-09-05}')), + # ], + # ids=['Instant days', 'Instant hours', + # 'Discrete Sequence days', 'Discrete Sequence hours', + # 'Sequence days', 'Sequence hours', + # 'Sequence Set days', 'Sequence Set hours'] + # ) + # def test_temporal_precision(self, tfloat, delta, expected): + # assert tfloat.temporal_precision(delta) == expected + + @pytest.mark.parametrize( + 'tfloat, delta, expected', + [(tfs, timedelta(days=4), None), + (tfs, timedelta(hours=12), None), + (tfss, timedelta(days=4), None), + (tfss, timedelta(hours=12), + TFloatSeq('[1.5@2019-09-03, 1.5@2019-09-05]')), + ], + ids=['Sequence days', 'Sequence hours', + 'Sequence Set days', 'Sequence Set hours'] ) - def test_to_tint(self, temporal, expected): - temp = temporal.to_tint() - assert isinstance(temp, TInt) - assert temp == expected + def test_stops(self, tfloat, delta, expected): + assert tfloat.stops(0.0, delta) == expected @pytest.mark.parametrize( 'temporal, expected', [ - (tfi, floatrange(1.5, 1.5, True, True)), - (tfds, floatrange(1.5, 2.5, True, True)), - (tfs, floatrange(1.5, 2.5, True, True)), - (tfss, floatrange(1.5, 2.5, True, True)), + (TFloatInst('1.123456789@2019-09-01'), + TFloatInst('1.12@2019-09-01')), + (TFloatSeq('{1.123456789@2019-09-01,' + '2.123456789@2019-09-02}'), + TFloatSeq('{1.12@2019-09-01, 2.12@2019-09-02}')), + (TFloatSeq('[1.123456789@2019-09-01, 2.123456789@2019-09-02]'), + TFloatSeq('[1.12@2019-09-01, 2.12@2019-09-02]')), + (TFloatSeqSet('{[1.123456789@2019-09-01, 2.123456789@2019-09-02],' + '[1.123456789@2019-09-03, 1.123456789@2019-09-05]}'), + TFloatSeq('{[1.12@2019-09-01, 2.12@2019-09-02],' + '[1.12@2019-09-03, 1.12@2019-09-05]}')), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_to_floatrange(self, temporal, expected): - assert temporal.to_floatrange() == expected + def test_round(self, temporal, expected): + assert temporal.round(maxdd=2) class TestTFloatModifications(TestTFloat): @@ -1006,23 +1181,17 @@ class TestTFloatMathematicalOperations(TestTFloat): tfds = TFloatSeq('{1.5@2019-09-01, 2.5@2019-09-02}') tfs = TFloatSeq('[1.5@2019-09-01, 2.5@2019-09-02]') tfss = TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02],[1.5@2019-09-03, 1.5@2019-09-05]}') - tintarg = TIntSeq('[2@2019-09-01, 1@2019-09-02, 1@2019-09-03]') tfloatarg = TFloatSeq('[2.5@2019-09-01, 1.5@2019-09-02, 1.5@2019-09-03]') @pytest.mark.parametrize( 'temporal, argument, expected', [ - (tfi, tintarg, TFloatInst('3.5@2019-09-01')), - (tfds, tintarg, TFloatSeq('{3.5@2019-09-01, 3.5@2019-09-02}')), - (tfs, tintarg, TFloatSeqSet('{[3.5@2019-09-01, 4.5@2019-09-02),[3.5@2019-09-02]}')), - (tfss, tintarg, TFloatSeqSet('{[3.5@2019-09-01, 4.5@2019-09-02),[3.5@2019-09-02],[2.5@2019-09-03]}')), (tfi, tfloatarg, TFloatInst('4@2019-09-01')), (tfds, tfloatarg, TFloatSeq('{4@2019-09-01, 4@2019-09-02}')), (tfs, tfloatarg, TFloatSeqSet('{[4@2019-09-01, 4@2019-09-02]}')), (tfss, tfloatarg, TFloatSeqSet('{[4@2019-09-01, 4@2019-09-02],[3@2019-09-03]}')), ], - ids=['Instant TInt', 'Discrete Sequence TInt', 'Sequence TInt', 'SequenceSet TInt', - 'Instant TFloat', 'Discrete Sequence TFloat', 'Sequence TFloat', 'SequenceSet TFloat'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_temporal_add_temporal(self, temporal, argument, expected): assert temporal.add(argument) == expected @@ -1040,28 +1209,19 @@ def test_temporal_add_temporal(self, temporal, argument, expected): ) def test_temporal_add_int_float(self, temporal, argument, expected): assert temporal.add(argument) == expected - assert temporal.add(float(argument)) == expected assert temporal.radd(argument) == expected - assert temporal.radd(float(argument)) == expected assert (temporal + argument) == expected - assert (temporal + float(argument)) == expected assert (argument + temporal) == expected - assert (float(argument) + temporal) == expected @pytest.mark.parametrize( 'temporal, argument, expected', [ - (tfi, tintarg, TFloatInst('-0.5@2019-09-01')), - (tfds, tintarg, TFloatSeq('{-0.5@2019-09-01, 1.5@2019-09-02}')), - (tfs, tintarg, TFloatSeqSet('{[-0.5@2019-09-01, 0.5@2019-09-02), [1.5@2019-09-02]}')), - (tfss, tintarg, TFloatSeqSet('{[-0.5@2019-09-01, 0.5@2019-09-02), [1.5@2019-09-02],[0.5@2019-09-03]}')), (tfi, tfloatarg, TFloatInst('-1@2019-09-01')), (tfds, tfloatarg, TFloatSeq('{-1@2019-09-01, 1@2019-09-02}')), (tfs, tfloatarg, TFloatSeqSet('{[-1@2019-09-01, 1@2019-09-02]}')), (tfss, tfloatarg, TFloatSeqSet('{[-1@2019-09-01, 1@2019-09-02],[0@2019-09-03]}')), ], - ids=['Instant TInt', 'Discrete Sequence TInt', 'Sequence TInt', 'SequenceSet TInt', - 'Instant TFloat', 'Discrete Sequence TFloat', 'Sequence TFloat', 'SequenceSet TFloat'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_temporal_sub_temporal(self, temporal, argument, expected): assert temporal.sub(argument) == expected @@ -1079,28 +1239,19 @@ def test_temporal_sub_temporal(self, temporal, argument, expected): ) def test_temporal_sub_int_float(self, temporal, argument, expected): assert temporal.sub(argument) == expected - assert temporal.sub(float(argument)) == expected assert temporal.rsub(argument) == -1 * expected - assert temporal.rsub(float(argument)) == -1 * expected assert (temporal - argument) == expected - assert (temporal - float(argument)) == expected assert (argument - temporal) == -1 * expected - assert (float(argument) - temporal) == -1 * expected @pytest.mark.parametrize( 'temporal, argument, expected', [ - (tfi, tintarg, TFloatInst('3@2019-09-01')), - (tfds, tintarg, TFloatSeq('{3@2019-09-01, 2.5@2019-09-02}')), - (tfs, tintarg, TFloatSeqSet('{[3@2019-09-01, 5@2019-09-02 00:00:00+00), [2.5@2019-09-02]}')), - (tfss, tintarg, TFloatSeqSet('{[3@2019-09-01, 5@2019-09-02 00:00:00+00), [2.5@2019-09-02],[1.5@2019-09-03]}')), (tfi, tfloatarg, TFloatInst('3.75@2019-09-01')), (tfds, tfloatarg, TFloatSeq('{3.75@2019-09-01, 3.75@2019-09-02}')), (tfs, tfloatarg, TFloatSeqSet('{[3.75@2019-09-01, 4@2019-09-01 12:00:00+00, 3.75@2019-09-02]}')), (tfss, tfloatarg, TFloatSeqSet('{[3.75@2019-09-01, 4@2019-09-01 12:00:00+00, 3.75@2019-09-02], [2.25@2019-09-03]}')), ], - ids=['Instant TInt', 'Discrete Sequence TInt', 'Sequence TInt', 'SequenceSet TInt', - 'Instant TFloat', 'Discrete Sequence TFloat', 'Sequence TFloat', 'SequenceSet TFloat'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_temporal_mul_temporal(self, temporal, argument, expected): assert temporal.mul(argument) == expected @@ -1133,25 +1284,16 @@ def test_temporal_mul_int_float(self, temporal, argument, expected): assert temporal.rmul(argument) == expected assert (temporal * argument) == expected assert (argument * temporal) == expected - assert temporal.mul(float(argument)) == expected - assert temporal.rmul(float(argument)) == expected - assert (temporal * float(argument)) == expected - assert (float(argument) * temporal) == expected @pytest.mark.parametrize( 'temporal, argument, expected', [ - (tfi, tintarg, TFloatInst('0.75@2019-09-01')), - (tfds, tintarg, TFloatSeq('{0.75@2019-09-01, 2.5@2019-09-02}')), - (tfs, tintarg, TFloatSeqSet('{[0.75@2019-09-01, 1.25@2019-09-02 00:00:00+00), [2.5@2019-09-02]}')), - (tfss, tintarg, TFloatSeqSet('{[0.75@2019-09-01, 1.25@2019-09-02 00:00:00+00), [2.5@2019-09-02], [1.5@2019-09-03]}')), (tfi, tfloatarg, TFloatInst('0.6@2019-09-01')), (tfds, tfloatarg, TFloatSeq('{0.6@2019-09-01, 1.667@2019-09-02}')), (tfs, tfloatarg, TFloatSeqSet('{[0.6@2019-09-01, 1@2019-09-01 12:00:00+00, 1.667@2019-09-02]}')), (tfss, tfloatarg, TFloatSeqSet('{[0.6@2019-09-01, 1@2019-09-01 12:00:00+00, 1.667@2019-09-02], [1@2019-09-03]}')), ], - ids=['Instant TInt', 'Discrete Sequence TInt', 'Sequence TInt', 'SequenceSet TInt', - 'Instant TFloat', 'Discrete Sequence TFloat', 'Sequence TFloat', 'SequenceSet TFloat'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_temporal_div_temporal(self, temporal, argument, expected): assert temporal.div(argument).round(3) == expected @@ -1174,9 +1316,7 @@ def test_temporal_div_temporal(self, temporal, argument, expected): ) def test_temporal_div_int_float(self, temporal, argument, expected): assert temporal.div(argument) == expected - assert temporal.div(float(argument)) == expected assert (temporal / argument) == expected - assert (temporal / float(argument)) == expected @pytest.mark.parametrize( 'temporal', @@ -1190,16 +1330,18 @@ def test_abs(self, temporal): @pytest.mark.parametrize( 'temporal, expected', [ - # (tfi, TFloatInst('1@2019-09-01')), + (tfi, None), (tfds, TFloatSeq('{1@2019-09-01, 1@2019-09-02}')), (tfs, TFloatSeq('Interp=Step;[1@2019-09-01, 1@2019-09-02)')), (tfss, TFloatSeqSet('Interp=Step;{[1@2019-09-01, 1@2019-09-02),[0@2019-09-03, 0@2019-09-05)}')), ], - ids=[# 'Instant', - 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_delta_value(self, temporal, expected): - assert temporal.delta_value() == expected + if expected is None: + assert temporal.delta_value() is None + else: + assert temporal.delta_value() == expected @pytest.mark.parametrize( 'temporal, expected', @@ -1225,16 +1367,18 @@ def test_to_radians_to_degrees(self, temporal): @pytest.mark.parametrize( 'temporal, expected', [ - # (tfi, None), - # (tfds, None), + (tfi, None), + (tfds, None), (tfs, TFloatSeq('Interp=Step;[-1@2019-09-01, -1@2019-09-02]')), (tfss, TFloatSeqSet('Interp=Step;{[-1@2019-09-01, -1@2019-09-02],[0@2019-09-03, 0@2019-09-05]}')), ], - ids=[ # 'Instant', 'Discrete Sequence', - 'Sequence', 'SequenceSet'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_derivative(self, temporal, expected): - assert temporal.derivative() * 3600 * 24 == expected + if expected is None: + assert temporal.derivative() is None + else: + assert temporal.derivative() * 3600 * 24 == expected class TestTFloatRestrictors(TestTFloat): @@ -1255,51 +1399,79 @@ class TestTFloatRestrictors(TestTFloat): (tfi, timestamp_set, TFloatInst('1.5@2019-09-01')), (tfi, period, TFloatInst('1.5@2019-09-01')), (tfi, period_set, TFloatInst('1.5@2019-09-01')), - (tfi, 1.5, TFloatInst('1.5@2019-09-01')), - (tfi, 2.5, None), - # (tfi, [1.5,2.5], TFloatInst('1.5@2019-09-01')), (tfds, timestamp, TFloatSeq('{1.5@2019-09-01}')), (tfds, timestamp_set, TFloatSeq('{1.5@2019-09-01}')), (tfds, period, TFloatSeq('{1.5@2019-09-01, 2.5@2019-09-02}')), (tfds, period_set, TFloatSeq('{1.5@2019-09-01, 2.5@2019-09-02}')), - (tfds, 1.5, TFloatSeq('{1.5@2019-09-01}')), - (tfds, 2.5, TFloatSeq('{2.5@2019-09-02}')), - # (tfds, [1.5,2.5], TFloatSeq('{1.5@2019-09-01}')), (tfs, timestamp, TFloatSeq('[1.5@2019-09-01]')), (tfs, timestamp_set, TFloatSeq('{1.5@2019-09-01}')), (tfs, period, TFloatSeq('[1.5@2019-09-01, 2.5@2019-09-02]')), (tfs, period_set, TFloatSeq('[1.5@2019-09-01, 2.5@2019-09-02]')), - (tfs, 1.5, TFloatSeq('[1.5@2019-09-01]')), - (tfs, 2.5, TFloatSeq('[2.5@2019-09-02]')), - # (tfs, [1.5,2.5], TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02)}')), (tfss, timestamp, TFloatSeqSet('[1.5@2019-09-01]')), (tfss, timestamp_set, TFloatSeq('{1.5@2019-09-01, 1.5@2019-09-03}')), (tfss, period, TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02]}')), (tfss, period_set, TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02],[1.5@2019-09-03, 1.5@2019-09-05]}')), - (tfss, 1.5, TFloatSeqSet('{[1.5@2019-09-01],[1.5@2019-09-03, 1.5@2019-09-05]}')), - (tfss, 2.5, TFloatSeqSet('{[2.5@2019-09-02]}')) - # (tfss, [1.5,2.5], TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02),[1.5@2019-09-03, 1.5@2019-09-05]}')) ], ids=['Instant-Timestamp', 'Instant-TimestampSet', 'Instant-Period', - 'Instant-PeriodSet', 'Instant-1_5', 'Instant-2_5', - #'Instant-[1.5,2.5]', + 'Instant-PeriodSet', 'Discrete Sequence-Timestamp', 'Discrete Sequence-TimestampSet', 'Discrete Sequence-Period', 'Discrete Sequence-PeriodSet', - 'Discrete Sequence-1_5', 'Discrete Sequence-2_5', - # 'Discrete Sequence-[1.5,2.5]' 'Sequence-Timestamp', 'Sequence-TimestampSet', 'Sequence-Period', - 'Sequence-PeriodSet', 'Sequence-1_5', 'Sequence-2_5', - # 'Sequence-[1.5,2.5]', - 'SequenceSet-Timestamp', 'SequenceSet-TimestampSet', 'SequenceSet-Period', - 'SequenceSet-PeriodSet', 'SequenceSet-1_5', 'SequenceSet-2_5', - #'SequenceSet-[1.5,2.5]' + 'Sequence-PeriodSet', + 'SequenceSet-Timestamp', 'SequenceSet-TimestampSet', + 'SequenceSet-Period', 'SequenceSet-PeriodSet', ] ) - def test_at(self, temporal, restrictor, expected): + def test_at_time(self, temporal, restrictor, expected): + assert temporal.at(restrictor) == expected + + @pytest.mark.parametrize( + 'temporal, restrictor, expected', + [ + (tfi, 1.5, TFloatInst('1.5@2019-09-01')), + (tfi, 2.5, None), + (tfi, floatrange(1.5, 1.5, True, True), TFloatInst('1.5@2019-09-01')), + # (tfi, [1.5,2.5], TFloatInst('1.5@2019-09-01')), + # (tfi, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)], + # TFloatInst('1.5@2019-09-01')), + + (tfds, 1.5, TFloatSeq('{1.5@2019-09-01}')), + (tfds, 2.5, TFloatSeq('{2.5@2019-09-02}')), + (tfds, floatrange(1.5, 1.5, True, True), TFloatInst('1.5@2019-09-01')), + # (tfds, [1.5,2.5], TFloatSeq('{1.5@2019-09-01}')), + # (tfds, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)], + # TFloatInst('1.5@2019-09-01')), + + (tfs, 1.5, TFloatSeq('[1.5@2019-09-01]')), + (tfs, 2.5, TFloatSeq('[2.5@2019-09-02]')), + (tfs, floatrange(1.5, 1.5, True, True), TFloatInst('1.5@2019-09-01')), + # (tfs, [1.5,2.5], TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02)}')), + # (tfs, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)], + # TFloatInst('1.5@2019-09-01')), + + (tfss, 1.5, TFloatSeqSet('{[1.5@2019-09-01],[1.5@2019-09-03, 1.5@2019-09-05]}')), + (tfss, 2.5, TFloatSeqSet('{[2.5@2019-09-02]}')), + (tfss, floatrange(1.5, 1.5, True, True), + TFloatSeqSet('{[1.5@2019-09-01],[1.5@2019-09-03, 1.5@2019-09-05]}')), + # (tfss, [1.5,2.5], TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02),[1.5@2019-09-03, 1.5@2019-09-05]}')) + # (tfss, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)], + # TFloatInst('1.5@2019-09-01')), + ], + ids=['Instant-1.5', 'Instant-2.5', 'Instant-Range', + # 'Instant-ValueList', 'Instant-RangeList', + 'Discrete Sequence-1.5', 'Discrete Sequence-2.5', 'Discrete Sequence-Range', + # 'Discrete Sequence-ValueList', 'Discrete Sequence-RangeList' + 'Sequence-1.5', 'Sequence-2.5', 'Sequence-Range', + # 'Sequence-ValueList', 'Sequence-RangeList', + 'SequenceSet-1.5', 'SequenceSet-2.5', 'Sequence Set-Range', + # 'SequenceSet-ValueList', 'SequenceSet-RangeList' + ] + ) + def test_at_values(self, temporal, restrictor, expected): assert temporal.at(restrictor) == expected @pytest.mark.parametrize( @@ -1335,25 +1507,16 @@ def test_at_max(self, temporal, expected): (tfi, timestamp_set, None), (tfi, period, None), (tfi, period_set, None), - (tfi, 1.5, None), - (tfi, 2.5, TFloatInst('1.5@2019-09-01')), - # (tfi, [1.5,2.5], TFloatInst('1.5@2019-09-01')), (tfds, timestamp, TFloatSeq('{2.5@2019-09-02}')), (tfds, timestamp_set, TFloatSeq('{2.5@2019-09-02}')), (tfds, period, None), (tfds, period_set, None), - (tfds, 1.5, TFloatSeq('{2.5@2019-09-02}')), - (tfds, 2.5, TFloatSeq('{1.5@2019-09-01}')), - # (tfds, [1.5,2.5], TFloatSeq('{1.5@2019-09-01}')), (tfs, timestamp, TFloatSeqSet('{(1.5@2019-09-01, 2.5@2019-09-02]}')), (tfs, timestamp_set, TFloatSeqSet('{(1.5@2019-09-01, 2.5@2019-09-02]}')), (tfs, period, None), (tfs, period_set, None), - (tfs, 1.5, TFloatSeqSet('{(1.5@2019-09-01, 2.5@2019-09-02]}')), - (tfs, 2.5, TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02)}')), - # (tfs, [1.5,2.5], TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02)}')), (tfss, timestamp, TFloatSeqSet('{(1.5@2019-09-01, 2.5@2019-09-02],[1.5@2019-09-03, 1.5@2019-09-05]}')), @@ -1361,28 +1524,67 @@ def test_at_max(self, temporal, expected): TFloatSeqSet('{(1.5@2019-09-01, 2.5@2019-09-02],(1.5@2019-09-03, 1.5@2019-09-05]}')), (tfss, period, TFloatSeqSet('{[1.5@2019-09-03, 1.5@2019-09-05]}')), (tfss, period_set, None), - (tfss, 1.5, TFloatSeqSet('{(1.5@2019-09-01, 2.5@2019-09-02]}')), - (tfss, 2.5, TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02),[1.5@2019-09-03, 1.5@2019-09-05]}')), - # (tfss, [1.5,2.5], TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02),[1.5@2019-09-03, 1.5@2019-09-05]}')) ], ids=['Instant-Timestamp', 'Instant-TimestampSet', 'Instant-Period', - 'Instant-PeriodSet', 'Instant-1_5', 'Instant-2_5', - #'Instant-[1.5,2.5]', - 'Discrete Sequence-Timestamp', 'Discrete Sequence-TimestampSet', - 'Discrete Sequence-Period', 'Discrete Sequence-PeriodSet', - 'Discrete Sequence-1_5', 'Discrete Sequence-2_5', - # 'Discrete Sequence-[1.5,2.5]' - 'Sequence-Timestamp', 'Sequence-TimestampSet', 'Sequence-Period', - 'Sequence-PeriodSet', 'Sequence-1_5', 'Sequence-2_5', - # 'Sequence-[1.5,2.5]', - 'SequenceSet-Timestamp', 'SequenceSet-TimestampSet', 'SequenceSet-Period', - 'SequenceSet-PeriodSet', 'SequenceSet-1_5', 'SequenceSet-2_5', - #'SequenceSet-[1.5,2.5]' + 'Instant-PeriodSet', 'Discrete Sequence-Timestamp', + 'Discrete Sequence-TimestampSet', 'Discrete Sequence-Period', + 'Discrete Sequence-PeriodSet', 'Sequence-Timestamp', + 'Sequence-TimestampSet', 'Sequence-Period', 'Sequence-PeriodSet', + 'SequenceSet-Timestamp', 'SequenceSet-TimestampSet', + 'SequenceSet-Period', 'SequenceSet-PeriodSet', ] ) - def test_minus(self, temporal, restrictor, expected): + def test_minus_time(self, temporal, restrictor, expected): assert temporal.minus(restrictor) == expected + @pytest.mark.parametrize( + 'temporal, restrictor, expected', + [ + (tfi, 1.5, None), + (tfi, 2.5, TFloatInst('1.5@2019-09-01')), + (tfi, floatrange(1.5, 1.5, True, True), None), + # (tfi, [1.5,2.5], TFloatInst('1.5@2019-09-01')), + # (tfi, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)], + # TFloatInst('1.5@2019-09-01')), + + (tfds, 1.5, TFloatSeq('{2.5@2019-09-02}')), + (tfds, 2.5, TFloatSeq('{1.5@2019-09-01}')), + (tfds, floatrange(1.5, 1.5, True, True), TFloatSeq('{2.5@2019-09-02}')), + # (tfds, [1.5,2.5], TFloatSeq('{1.5@2019-09-01}')), + # (tfds, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)], + # TFloatInst('1.5@2019-09-01')), + + (tfs, 1.5, TFloatSeqSet('{(1.5@2019-09-01, 2.5@2019-09-02]}')), + (tfs, 2.5, TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02)}')), + (tfs, floatrange(1.5, 1.5, True, True), TFloatSeqSet('{(1.5@2019-09-01, 2.5@2019-09-02]}')), + # (tfs, [1.5,2.5], TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02)}')), + # (tfs, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)], + # TFloatInst('1.5@2019-09-01')), + + (tfss, 1.5, TFloatSeqSet('{(1.5@2019-09-01, 2.5@2019-09-02]}')), + (tfss, 2.5, TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02),[1.5@2019-09-03, 1.5@2019-09-05]}')), + (tfs, floatrange(1.5, 1.5, True, True), TFloatSeqSet('{(1.5@2019-09-01, 2.5@2019-09-02]}')), + # (tfss, [1.5,2.5], TFloatSeqSet('{[1.5@2019-09-01, 2.5@2019-09-02),[1.5@2019-09-03, 1.5@2019-09-05]}')) + # (tfss, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)], + # TFloatInst('1.5@2019-09-01')), + ], + ids=['Instant-1.5', 'Instant-2.5', 'Instant-Range', + # 'Instant-ValueList', 'Instant-RangeList', + 'Discrete Sequence-1.5', 'Discrete Sequence-2.5', + 'Discrete Sequence-Range', + # 'Discrete Sequence-ValueList' 'Discrete Sequence-RangeList', + 'Sequence-1.5', 'Sequence-2.5', 'Sequence-Range', + # 'Sequence-ValueList', 'Sequence-RangeList', + 'SequenceSet-1.5', 'SequenceSet-2.5', 'Sequence Set-Range', + # 'SequenceSet-ValueList', 'SequenceSet-RangeList', + ] + ) + def test_minus_values(self, temporal, restrictor, expected): + if expected is None: + assert temporal.minus(restrictor) is None + else: + assert temporal.minus(restrictor) == expected + @pytest.mark.parametrize( 'temporal, expected', [ @@ -1416,47 +1618,74 @@ def test_minus_max(self, temporal, expected): (tfi, timestamp_set), (tfi, period), (tfi, period_set), - (tfi, 1.5), - (tfi, 2.5), - # (tfi, [1.5,2.5]), (tfds, timestamp), (tfds, timestamp_set), (tfds, period), (tfds, period_set), - (tfds, 1.5), - (tfds, 2.5), - # (tfds, [1.5,2.5]), (tfs, timestamp), (tfs, timestamp_set), (tfs, period), (tfs, period_set), - (tfs, 1.5), - (tfs, 2.5), - # (tfs, [1.5,2.5]), (tfss, timestamp), (tfss, timestamp_set), (tfss, period), (tfss, period_set), - (tfss, 1.5), - (tfss, 2.5), - # (tfss, [1.5,2.5]), ], ids=['Instant-Timestamp', 'Instant-TimestampSet', 'Instant-Period', - 'Instant-PeriodSet', 'Instant-1_5', 'Instant-2_5', # 'Instant-[1.5,2.5]' + 'Instant-PeriodSet', 'Discrete Sequence-Timestamp', 'Discrete Sequence-TimestampSet', 'Discrete Sequence-Period', 'Discrete Sequence-PeriodSet', - 'Discrete Sequence-1_5', 'Discrete Sequence-2_5', # 'Discrete Sequence-[1.5,2.5]', 'Sequence-Timestamp', 'Sequence-TimestampSet', 'Sequence-Period', - 'Sequence-PeriodSet', 'Sequence-1_5', 'Sequence-2_5', # 'Sequence-[1.5,2.5]' + 'Sequence-PeriodSet', 'SequenceSet-Timestamp', 'SequenceSet-TimestampSet', 'SequenceSet-Period', - 'SequenceSet-PeriodSet', 'SequenceSet-1_5', 'SequenceSet-2_5', - # 'SequenceSet-[1.5,2.5]' + 'SequenceSet-PeriodSet', + ] + ) + def test_at_minus_time(self, temporal, restrictor): + assert TFloat.merge(temporal.at(restrictor), temporal.minus(restrictor)) == temporal + + @pytest.mark.parametrize( + 'temporal, restrictor', + [ + (tfi, 1.5), + (tfi, 2.5), + (tfi, floatrange(1.5, 1.5, True, True)), + # (tfi, [1.5,2.5]), + # (tfi, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)]), + + (tfds, 1.5), + (tfds, 2.5), + (tfds, floatrange(1.5, 1.5, True, True)), + # (tfds, [1.5,2.5]), + # (tfds, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)]), + + (tfs, 1.5), + (tfs, 2.5), + (tfs, floatrange(1.5, 1.5, True, True)), + # (tfs, [1.5,2.5]), + # (tfs, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)]), + + (tfss, 1.5), + (tfss, 2.5), + (tfss, floatrange(1.5, 1.5, True, True)), + # (tfss, [1.5,2.5]), + # (tfss, [floatrange(1.5, 1.5, True, True), floatrange(2.5, 2.5, True, True)]), + ], + ids=['Instant-1.5', 'Instant-2.5', 'Instant-Range', + # 'Instant-ValueList', 'Instant-RangeList', + 'Discrete Sequence-1.5', 'Discrete Sequence-2.5', + 'Discrete Sequence-Range', + # 'Discrete Sequence-ValueList', 'Discrete Sequence-RangeList', + 'Sequence-1.5', 'Sequence-2.5', 'Sequence-Range', + # 'Sequence-ValueList', 'Sequence-RangeList', + 'SequenceSet-1.5', 'SequenceSet-2.5', 'SequenceSet-Range', + # 'SequenceSet-ValueList', 'SequenceSet-RangeList', ] ) - def test_at_minus(self, temporal, restrictor): + def test_at_minus_values(self, temporal, restrictor): assert TFloat.merge(temporal.at(restrictor), temporal.minus(restrictor)) == temporal @pytest.mark.parametrize( diff --git a/pymeos/tests/main/tgeogpoint_test.py b/pymeos/tests/main/tgeogpoint_test.py index 3702582d..6069d5c2 100644 --- a/pymeos/tests/main/tgeogpoint_test.py +++ b/pymeos/tests/main/tgeogpoint_test.py @@ -3,11 +3,15 @@ from datetime import datetime, timezone, timedelta import pytest +import numpy as np from shapely import Point import shapely.geometry -from pymeos import TBool, TBoolInst, TBoolSeq, TBoolSeqSet, TFloat, TFloatInst, TFloatSeq, TFloatSeqSet, TGeogPoint, \ - TGeogPointInst, TGeogPointSeq, TGeogPointSeqSet, STBox, TInterpolation, TimestampSet, Period, PeriodSet +from pymeos import TBool, TBoolInst, TBoolSeq, TBoolSeqSet, \ + TFloat, TFloatInst, TFloatSeq, TFloatSeqSet, \ + TGeomPoint, TGeomPointInst, TGeomPointSeq, TGeomPointSeqSet, \ + TGeogPoint, TGeogPointInst, TGeogPointSeq, TGeogPointSeqSet, \ + STBox, TInterpolation, TimestampSet, Period, PeriodSet from tests.conftest import TestPyMEOS @@ -408,6 +412,19 @@ class TestTGeogPointAccessors(TestTGeogPoint): tps = TGeogPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]') tpss = TGeogPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}') + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, STBox('GEODSTBOX XT(((1,1),(1,1)),[2019-09-01, 2019-09-01])')), + (tpds, STBox('GEODSTBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])')), + (tps, STBox('GEODSTBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])')), + (tpss, STBox('GEODSTBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-05])')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_bounding_box(self, temporal, expected): + assert temporal.bounding_box() == expected + @pytest.mark.parametrize( 'temporal, expected', [ @@ -594,27 +611,27 @@ def test_end_instant(self, temporal, expected): 'temporal, expected', [ (tpi, tpi), - (tpds, TGeogPointInst('Point(2 2)@2019-09-02')), - (tps, TGeogPointInst('Point(2 2)@2019-09-02')), - (tpss, TGeogPointInst('Point(2 2)@2019-09-02')), + (tpds, tpi), + (tps, tpi), + (tpss, tpi), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_max_instant(self, temporal, expected): - assert temporal.max_instant() == expected + def test_min_instant(self, temporal, expected): + assert temporal.min_instant() == expected @pytest.mark.parametrize( 'temporal, expected', [ (tpi, tpi), - (tpds, tpi), - (tps, tpi), - (tpss, tpi), + (tpds, TGeogPointInst('Point(2 2)@2019-09-02')), + (tps, TGeogPointInst('Point(2 2)@2019-09-02')), + (tpss, TGeogPointInst('Point(2 2)@2019-09-02')), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_min_instant(self, temporal, expected): - assert temporal.min_instant() == expected + def test_max_instant(self, temporal, expected): + assert temporal.max_instant() == expected @pytest.mark.parametrize( 'temporal, n, expected', @@ -726,6 +743,23 @@ def test_timestamps(self, temporal, expected): def test_segments(self, temporal, expected): assert temporal.segments() == expected + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, 1181779687), + (tpds, 1545137628), + (tps, 1545137628), + (tpss, 1008965061) + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_hash(self, temporal, expected): + assert hash(temporal) == expected + + def test_value_timestamp(self): + assert self.tpi.value() == Point(1,1) + assert self.tpi.timestamp() == datetime(year=2019, month=9, day=1, tzinfo=timezone.utc) + @pytest.mark.parametrize( 'temporal, expected', [ @@ -738,18 +772,220 @@ def test_lower_upper_inc(self, temporal, expected): assert temporal.lower_inc() == expected assert temporal.upper_inc() == expected + def test_sequenceset_sequence_functions(self): + tpss1 =TGeogPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],' + '[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05], [Point(3 3)@2019-09-06]}') + assert tpss1.num_sequences() == 3 + assert tpss1.start_sequence() == TGeogPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]') + assert tpss1.end_sequence() == TGeogPointSeq('[Point(3 3)@2019-09-06]') + assert tpss1.sequence_n(1) == TGeogPointSeq('[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]') + assert tpss1.sequences() == [TGeogPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]'), + TGeogPointSeq('[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]'), + TGeogPointSeq('[Point(3 3)@2019-09-06]')] + + +class TestTGeogPointTPointAccessors(TestTGeogPoint): + tpi = TGeogPointInst('Point(1 1)@2019-09-01') + tpds = TGeogPointSeq('{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}') + tps = TGeogPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]') + tpss = TGeogPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}') + tpi3d = TGeogPointInst('Point(1 1 1)@2019-09-01') + tpds3d = TGeogPointSeq('{Point(1 1 1)@2019-09-01, Point(2 2 2)@2019-09-02}') + tps3d = TGeogPointSeq('[Point(1 1 1)@2019-09-01, Point(2 2 2)@2019-09-02]') + tpss3d = TGeogPointSeqSet('{[Point(1 1 1)@2019-09-01, Point(2 2 2)@2019-09-02],' + '[Point(1 1 1)@2019-09-03, Point(1 1 1)@2019-09-05]}') + @pytest.mark.parametrize( 'temporal, expected', [ - (tpi, 1181779687), - (tpds, 1545137628), - (tps, 1545137628), - (tpss, 1008965061) + (tpi, 0), + (tpds, 0), + (tps, 156876.1494), + (tpss, 156876.1494), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_hash(self, temporal, expected): - assert hash(temporal) == expected + def test_length(self, temporal, expected): + assert round(temporal.length(),4) == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, TFloatInst('0@2019-09-01')), + (tpds, TFloatSeq('{0@2019-09-01, 0@2019-09-02}')), + (tps, TFloatSeq('[0@2019-09-01, 156876.1494@2019-09-02]')), + (tpss, TFloatSeqSet('{[0@2019-09-01, 156876.1494@2019-09-02],' + '[156876.1494@2019-09-03, 156876.1494@2019-09-05]}')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_cumulative_length(self, temporal, expected): + assert temporal.cumulative_length().round(4) == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, None), + (tpds, None), + (tps, TFloatSeq('Interp=Step;[1.8157@2019-09-01, 1.8157@2019-09-02]')), + (tpss, TFloatSeqSet('Interp=Step;{[1.8157@2019-09-01, 1.8157@2019-09-02],' + '[0@2019-09-03, 0@2019-09-05]}')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_speed(self, temporal, expected): + if expected is None: + assert temporal.speed() is None + else: + assert temporal.speed().round(4) == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, TFloatInst('1@2019-09-01')), + (tpds, TFloatSeq('{1@2019-09-01, 2@2019-09-02}')), + (tps, TFloatSeq('[1@2019-09-01, 2@2019-09-02]')), + (tpss, TFloatSeqSet('{[1@2019-09-01, 2@2019-09-02],' + '[1@2019-09-03, 1@2019-09-05]}')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_x_y(self, temporal, expected): + assert temporal.x() == expected + assert temporal.y() == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi3d, TFloatInst('1@2019-09-01')), + (tpds3d, TFloatSeq('{1@2019-09-01, 2@2019-09-02}')), + (tps3d, TFloatSeq('[1@2019-09-01, 2@2019-09-02]')), + (tpss3d, TFloatSeqSet('{[1@2019-09-01, 2@2019-09-02],' + '[1@2019-09-03, 1@2019-09-05]}')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_x_y_z(self, temporal, expected): + assert temporal.x() == expected + assert temporal.y() == expected + assert temporal.z() == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, False), + (tpds, False), + (tps, False), + (tpss, False), + (tpi3d, True), + (tpds3d, True), + (tps3d, True), + (tpss3d, True), + ], + ids=['Instant 2D', 'Discrete Sequence 2D', 'Sequence 2D', 'SequenceSet 2D', + 'Instant 3D', 'Discrete Sequence 3D', 'Sequence 3D', 'SequenceSet 3D'] + ) + def test_has_z(self, temporal, expected): + assert temporal.has_z() == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi3d, True), + (tpds3d, True), + (tps3d, True), + (tpss3d, True), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_has_z(self, temporal, expected): + assert temporal.has_z() == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, []), + (tpds, []), + (tps, [STBox('GEODSTBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])')]), + (tpss, [STBox('GEODSTBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])'), + STBox('GEODSTBOX XT(((1,1),(1,1)),[2019-09-03, 2019-09-05])')]), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_stboxes(self, temporal, expected): + assert temporal.stboxes() == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, True), + (tpds, True), + (tps, True), + (tpss, True), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_is_simple(self, temporal, expected): + assert temporal.is_simple() == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, TFloatInst('0.7846@2019-09-01')), + (tpds, TFloatSeq('{0.7846@2019-09-01,0.7846@2019-09-02}')), + (tps, TFloatSeq('[0.7846@2019-09-01,0.7846@2019-09-02]')), + (tpss, TFloatSeqSet('{[0.7846@2019-09-01,0.7846@2019-09-02],' + '[0.7846@2019-09-03,0.7846@2019-09-05]}')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_bearing(self, temporal, expected): + assert temporal.bearing(shapely.set_srid(shapely.Point(3,3), 4326)).round(4) == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, None), + (tpds, 45.1705), + (tps, 45.1705), + (tpss, None), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_direction(self, temporal, expected): + res = temporal.direction() + result = round(np.rad2deg(res), 4) if res is not None else None + assert result == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, None), + (tpds, None), + (tps, TFloatSeqSet('Interp=Step;{[0.7884@2019-09-01,0.7884@2019-09-02]}')), + (tpss, TFloatSeqSet('Interp=Step;{[0.7884@2019-09-01,0.7884@2019-09-02]}')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_azimuth(self, temporal, expected): + res = temporal.azimuth() + result = res.round(4) if res is not None else None + assert result == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, None), + (tpds, None), + (tps, TFloatSeq('{0@2019-09-01,0@2019-09-02}')), + (tpss, TFloatSeqSet('{0@2019-09-01,0@2019-09-02}')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_angular_difference(self, temporal, expected): + res = temporal.angular_difference() + result = res.to_degrees() if res is not None else None + assert result == expected @pytest.mark.parametrize( 'temporal, expected', @@ -764,18 +1000,26 @@ def test_hash(self, temporal, expected): def test_srid(self, temporal, expected): assert temporal.srid() == expected + +class TestTGeogPointConversions(TestTGeogPoint): + tpi = TGeogPointInst('Point(1 1)@2019-09-01') + tpds = TGeogPointSeq('{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}') + tps = TGeogPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]') + tpss = TGeogPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}') + @pytest.mark.parametrize( 'temporal, expected', [ - (tpi, STBox('GEODSTBOX XT(((1,1),(1,1)),[2019-09-01, 2019-09-01])')), - (tpds, STBox('GEODSTBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])')), - (tps, STBox('GEODSTBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])')), - (tpss, STBox('GEODSTBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-05])')), + (tpi, TGeomPointInst('SRID=4326;Point(1 1)@2019-09-01')), + (tpds, TGeomPointSeq('SRID=4326;{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}')), + (tps, TGeomPointSeq('SRID=4326;[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]')), + (tpss, TGeomPointSeqSet('SRID=4326;{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],' + '[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}')), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_bounding_box(self, temporal, expected): - assert temporal.bounding_box() == expected + def test_to_geometric(self, temporal, expected): + assert temporal.to_geometric() == expected class TestTGeogPointTransformations(TestTGeogPoint): @@ -784,6 +1028,15 @@ class TestTGeogPointTransformations(TestTGeogPoint): tps = TGeogPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]') tpss = TGeogPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}') + tps_d = TGeogPointSeq('[Point(1 1)@2019-09-01]') + tpss_d = TGeogPointSeqSet('{[Point(1 1)@2019-09-01],[Point(2 2)@2019-09-03]}') + tps_s = TGeogPointSeq('[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]') + tpss_s = TGeogPointSeqSet('{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02],' + '[Point(2 2)@2019-09-03, Point(2 2)@2019-09-05]}') + tps_l = TGeogPointSeq('Interp=Step;[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]') + tpss_l = TGeogPointSeqSet('Interp=Step;{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],' + '[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}') + @pytest.mark.parametrize( 'temporal, expected', [ @@ -837,6 +1090,44 @@ def test_to_sequenceset(self, temporal, expected): assert isinstance(temp, TGeogPointSeqSet) assert temp == expected + @pytest.mark.parametrize( + 'temporal, interpolation, expected', + [ + (tpi, TInterpolation.DISCRETE, + TGeogPointSeq('{Point(1 1)@2019-09-01}')), + (tpds, TInterpolation.DISCRETE, tpds), + (tps_d, TInterpolation.DISCRETE, + TGeogPointSeq('{Point(1 1)@2019-09-01}')), + (tpss_d, TInterpolation.DISCRETE, + TGeogPointSeq('{Point(1 1)@2019-09-01,Point(2 2)@2019-09-03}')), + + (tpi, TInterpolation.STEPWISE, + TGeogPointSeq('Interp=Step;[Point(1 1)@2019-09-01]')), + (tpds, TInterpolation.STEPWISE, + TGeogPointSeqSet('Interp=Step;{[Point(1 1)@2019-09-01], [Point(2 2)@2019-09-02]}')), + (tps_s, TInterpolation.STEPWISE, + TGeogPointSeq('Interp=Step;[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]')), + (tpss_s, TInterpolation.STEPWISE, + TGeogPointSeqSet('Interp=Step;{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02],' + '[Point(2 2)@2019-09-03, Point(2 2)@2019-09-05]}')), + + (tpi, TInterpolation.LINEAR, + TGeogPointSeq('[Point(1 1)@2019-09-01]')), + (tpds, TInterpolation.LINEAR, + TGeogPointSeqSet('{[Point(1 1)@2019-09-01], [Point(2 2)@2019-09-02]}')), + (tps_l, TInterpolation.LINEAR, + TGeogPointSeqSet('{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02), [Point(2 2)@2019-09-02]}')), + (tpss_l, TInterpolation.LINEAR, + TGeogPointSeqSet('{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02),' + '[Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}')), + ], + ids=['Instant to discrete', 'Discrete Sequence to discrete', 'Sequence to discrete', 'SequenceSet to discrete', + 'Instant to step', 'Discrete Sequence to step', 'Sequence to step', 'SequenceSet to step', + 'Instant to linear', 'Discrete Sequence to linear', 'Sequence to linear', 'SequenceSet to linear'] + ) + def test_set_interpolation(self, temporal, interpolation, expected): + assert temporal.set_interpolation(interpolation) == expected + @pytest.mark.parametrize( 'tpoint, delta, expected', [(tpi, timedelta(days=4), TGeogPointInst('Point(1 1)@2019-09-05')), @@ -901,6 +1192,67 @@ def test_shift_tscale(self): TGeogPointSeqSet('{[Point(1 1)@2019-09-05 00:00:00, Point(2 2)@2019-09-05 00:30:00],' '[Point(1 1)@2019-09-05 01:00:00, Point(1 1)@2019-09-05 02:00:00]}') + @pytest.mark.parametrize( + 'tpoint, delta, expected', + [(tpi, timedelta(days=4), TGeogPointInst('Point(1 1)@2019-09-01')), + (tpi, timedelta(hours=12), TGeogPointInst('Point(1 1)@2019-09-01')), + (tpds, timedelta(days=4), TGeogPointSeq('{Point(1 1)@2019-09-01}')), + (tpds, timedelta(hours=12), TGeogPointSeq('{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}')), + (tps, timedelta(days=4), TGeogPointSeq('{Point(1 1)@2019-09-01}')), + (tps, timedelta(hours=12), TGeogPointSeq('{Point(1 1)@2019-09-01, Point(1.5 1.5)@2019-09-01 12:00:00, Point(2 2)@2019-09-02}')), + (tpss, timedelta(days=4), + TGeogPointSeq('{Point(1 1)@2019-09-01,Point(1 1)@2019-09-05}')), + (tpss, timedelta(hours=12), + TGeogPointSeq('{Point(1 1)@2019-09-01, Point(1.5 1.5)@2019-09-01 12:00:00,' + 'Point(2 2)@2019-09-02, Point(1 1)@2019-09-03, Point(1 1)@2019-09-03 12:00:00, ' + 'Point(1 1)@2019-09-04, Point(1 1)@2019-09-04 12:00:00, Point(1 1)@2019-09-05}')), + ], + ids=['Instant days', 'Instant hours', + 'Discrete Sequence days', 'Discrete Sequence hours', + 'Sequence days', 'Sequence hours', + 'Sequence Set days', 'Sequence Set hours' + ] + ) + def test_temporal_sample(self, tpoint, delta, expected): + assert tpoint.temporal_sample(delta).round(1) == expected + + @pytest.mark.parametrize( + 'tpoint, delta, expected', + [(tps, timedelta(days=4), None), + (tps, timedelta(hours=12), None), + (tpss, timedelta(days=4), None), + (tpss, timedelta(hours=12), + TGeogPointSeq('[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]')), + ], + ids=['Sequence days', 'Sequence hours', + 'Sequence Set days', 'Sequence Set hours'] + ) + def test_stops(self, tpoint, delta, expected): + assert tpoint.stops(0.0, delta) == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (TGeogPointInst('Point(1.123456789 1.123456789)@2019-09-01'), + TGeogPointInst('Point(1.12 1.12)@2019-09-01')), + (TGeogPointSeq('{Point(1.123456789 1.123456789)@2019-09-01,' + 'Point(2.123456789 2.123456789)@2019-09-02}'), + TGeogPointSeq('{Point(1.12 1.12)@2019-09-01,Point(2.12 2.12)@2019-09-02}')), + (TGeogPointSeq('[Point(1.123456789 1.123456789)@2019-09-01,' + 'Point(2.123456789 2.123456789)@2019-09-02]'), + TGeogPointSeq('[Point(1.12 1.12)@2019-09-01,Point(2.12 2.12)@2019-09-02]')), + (TGeogPointSeqSet('{[Point(1.123456789 1.123456789)@2019-09-01,' + 'Point(2.123456789 2.123456789)@2019-09-02],' + '[Point(1.123456789 1.123456789)@2019-09-03,' + 'Point(1.123456789 1.123456789)@2019-09-05]}'), + TGeogPointSeq('{[Point(1.12 1.12)@2019-09-01,Point(2.12 2.12)@2019-09-02],' + '[Point(1.12 1.12)@2019-09-03,Point(1.12 1.12)@2019-09-05]}')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_round(self, temporal, expected): + assert temporal.round(maxdd=2) + class TestTGeogPointModifications(TestTGeogPoint): tpi = TGeogPointInst('Point(1 1)@2019-09-01') diff --git a/pymeos/tests/main/tgeompoint_test.py b/pymeos/tests/main/tgeompoint_test.py index 1be059b9..55d0a1ca 100644 --- a/pymeos/tests/main/tgeompoint_test.py +++ b/pymeos/tests/main/tgeompoint_test.py @@ -4,6 +4,7 @@ import pytest import math +import numpy as np from shapely import Point, LineString, Polygon, MultiPoint, GeometryCollection from pymeos import TBool, TBoolInst, TBoolSeq, TBoolSeqSet, \ @@ -433,6 +434,19 @@ class TestTGeomPointTemporalAccessors(TestTGeomPoint): tpss3d = TGeomPointSeqSet('{[Point(1 1 1)@2019-09-01, Point(2 2 2)@2019-09-02],' '[Point(1 1 1)@2019-09-03, Point(1 1 1)@2019-09-05]}') + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, STBox('STBOX XT(((1,1),(1,1)),[2019-09-01, 2019-09-01])')), + (tpds, STBox('STBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])')), + (tps, STBox('STBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])')), + (tpss, STBox('STBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-05])')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_bounding_box(self, temporal, expected): + assert temporal.bounding_box() == expected + @pytest.mark.parametrize( 'temporal, expected', [ @@ -619,27 +633,27 @@ def test_end_instant(self, temporal, expected): 'temporal, expected', [ (tpi, tpi), - (tpds, TGeomPointInst('Point(2 2)@2019-09-02')), - (tps, TGeomPointInst('Point(2 2)@2019-09-02')), - (tpss, TGeomPointInst('Point(2 2)@2019-09-02')), + (tpds, tpi), + (tps, tpi), + (tpss, tpi), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_max_instant(self, temporal, expected): - assert temporal.max_instant() == expected + def test_min_instant(self, temporal, expected): + assert temporal.min_instant() == expected @pytest.mark.parametrize( 'temporal, expected', [ (tpi, tpi), - (tpds, tpi), - (tps, tpi), - (tpss, tpi), + (tpds, TGeomPointInst('Point(2 2)@2019-09-02')), + (tps, TGeomPointInst('Point(2 2)@2019-09-02')), + (tpss, TGeomPointInst('Point(2 2)@2019-09-02')), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_min_instant(self, temporal, expected): - assert temporal.min_instant() == expected + def test_max_instant(self, temporal, expected): + assert temporal.max_instant() == expected @pytest.mark.parametrize( 'temporal, n, expected', @@ -780,11 +794,7 @@ def test_lower_upper_inc(self, temporal, expected): assert temporal.lower_inc() == expected assert temporal.upper_inc() == expected - def test_instant_functions(self): - assert self.tpi.value() == Point(1,1) - assert self.tpi.timestamp() == datetime(year=2019, month=9, day=1, tzinfo=timezone.utc) - - def test_sequenceset_functions(self): + def test_sequenceset_sequence_functions(self): tpss1 =TGeomPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],' '[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05], [Point(3 3)@2019-09-06]}') assert tpss1.num_sequences() == 3 @@ -807,19 +817,6 @@ class TestTGeomPointTPointAccessors(TestTGeomPoint): tpss3d = TGeomPointSeqSet('{[Point(1 1 1)@2019-09-01, Point(2 2 2)@2019-09-02],' '[Point(1 1 1)@2019-09-03, Point(1 1 1)@2019-09-05]}') - @pytest.mark.parametrize( - 'temporal, expected', - [ - (tpi, STBox('STBOX XT(((1,1),(1,1)),[2019-09-01, 2019-09-01])')), - (tpds, STBox('STBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])')), - (tps, STBox('STBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])')), - (tpss, STBox('STBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-05])')), - ], - ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] - ) - def test_bounding_box(self, temporal, expected): - assert temporal.bounding_box() == expected - @pytest.mark.parametrize( 'temporal, expected', [ @@ -847,19 +844,19 @@ def test_length(self, temporal, expected): def test_cumulative_length(self, temporal, expected): assert temporal.cumulative_length() == expected - @pytest.mark.parametrize( - 'temporal, expected', - [ - (tpi, None), - (tpds, None), - (tps, TFloatSeq('Interp=Step;[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02]') / 3600 / 24), - (tpss, TFloatSeqSet('Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02],' - '[0@2019-09-03, 0@2019-09-05]}') / 3600 / 24), - ], - ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] - ) - def test_speed(self, temporal, expected): - assert temporal.speed() == expected + # @pytest.mark.parametrize( + # 'temporal, expected', + # [ + # (tpi, None), + # (tpds, None), + # (tps, TFloatSeq('Interp=Step;[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02]') / 3600 / 24), + # (tpss, TFloatSeqSet('Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02],' + # '[0@2019-09-03, 0@2019-09-05]}') / 3600 / 24), + # ], + # ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + # ) + # def test_speed(self, temporal, expected): + # assert temporal.speed() == expected @pytest.mark.parametrize( 'temporal, expected', @@ -963,6 +960,21 @@ def test_is_simple(self, temporal, expected): def test_bearing(self, temporal, expected): assert temporal.bearing(Point(3,3)).to_degrees() == expected + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tpi, None), + (tpds, 45), + (tps, 45), + (tpss, None), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_direction(self, temporal, expected): + res = temporal.direction() + result = np.rad2deg(res) if res is not None else None + assert result == expected + @pytest.mark.parametrize( 'temporal, expected', [ @@ -1082,6 +1094,59 @@ class TestTGeomPointTransformations(TestTGeomPoint): tpss_l = TGeomPointSeqSet('Interp=Step;{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],' '[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}') + @pytest.mark.parametrize( + 'temporal, expected', + [ + (TGeomPointInst('Point(1 1)@2019-09-01'), tpi), + (TGeomPointSeq('{Point(1 1)@2019-09-01}'), tpi), + (TGeomPointSeq('[Point(1 1)@2019-09-01]'), tpi), + (TGeomPointSeqSet('{[Point(1 1)@2019-09-01]}'), tpi), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_to_instant(self, temporal, expected): + temp = temporal.to_instant() + assert isinstance(temp, TGeomPointInst) + assert temp == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (TGeomPointInst('Point(1 1)@2019-09-01'), + TGeomPointSeq('[Point(1 1)@2019-09-01]')), + (TGeomPointSeq('{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}'), + TGeomPointSeq('{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}')), + (TGeomPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]'), + TGeomPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]')), + (TGeomPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}'), + TGeomPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_to_sequence(self, temporal, expected): + temp = temporal.to_sequence() + assert isinstance(temp, TGeomPointSeq) + assert temp == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (TGeomPointInst('Point(1 1)@2019-09-01'), + TGeomPointSeqSet('{[Point(1 1)@2019-09-01]}')), + (TGeomPointSeq('{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}'), + TGeomPointSeqSet('{[Point(1 1)@2019-09-01], [Point(2 2)@2019-09-02]}')), + (TGeomPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]'), + TGeomPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}')), + (TGeomPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}'), + TGeomPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_to_sequenceset(self, temporal, expected): + temp = temporal.to_sequenceset() + assert isinstance(temp, TGeomPointSeqSet) + assert temp == expected + @pytest.mark.parametrize( 'temporal, interpolation, expected', [ @@ -1111,7 +1176,7 @@ class TestTGeomPointTransformations(TestTGeomPoint): TGeomPointSeqSet('{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02), [Point(2 2)@2019-09-02]}')), (tpss_l, TInterpolation.LINEAR, TGeomPointSeqSet('{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02),' - '[Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1 )@2019-09-05]}')), + '[Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}')), ], ids=['Instant to discrete', 'Discrete Sequence to discrete', 'Sequence to discrete', 'SequenceSet to discrete', 'Instant to step', 'Discrete Sequence to step', 'Sequence to step', 'SequenceSet to step', @@ -1185,57 +1250,42 @@ def test_shift_tscale(self): '[Point(1 1)@2019-09-05 01:00:00, Point(1 1)@2019-09-05 02:00:00]}') @pytest.mark.parametrize( - 'temporal, expected', - [ - (TGeomPointInst('Point(1 1)@2019-09-01'), tpi), - (TGeomPointSeq('{Point(1 1)@2019-09-01}'), tpi), - (TGeomPointSeq('[Point(1 1)@2019-09-01]'), tpi), - (TGeomPointSeqSet('{[Point(1 1)@2019-09-01]}'), tpi), - ], - ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] - ) - def test_to_instant(self, temporal, expected): - temp = temporal.to_instant() - assert isinstance(temp, TGeomPointInst) - assert temp == expected - - @pytest.mark.parametrize( - 'temporal, expected', - [ - (TGeomPointInst('Point(1 1)@2019-09-01'), - TGeomPointSeq('[Point(1 1)@2019-09-01]')), - (TGeomPointSeq('{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}'), - TGeomPointSeq('{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}')), - (TGeomPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]'), - TGeomPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]')), - (TGeomPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}'), - TGeomPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]')), - ], - ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + 'tpoint, delta, expected', + [(tpi, timedelta(days=4), TGeomPointInst('Point(1 1)@2019-09-01')), + (tpi, timedelta(hours=12), TGeomPointInst('Point(1 1)@2019-09-01')), + (tpds, timedelta(days=4), TGeomPointSeq('{Point(1 1)@2019-09-01}')), + (tpds, timedelta(hours=12), TGeomPointSeq('{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}')), + (tps, timedelta(days=4), TGeomPointSeq('{Point(1 1)@2019-09-01}')), + (tps, timedelta(hours=12), TGeomPointSeq('{Point(1 1)@2019-09-01, Point(1.5 1.5)@2019-09-01 12:00:00, Point(2 2)@2019-09-02}')), + (tpss, timedelta(days=4), + TGeomPointSeq('{Point(1 1)@2019-09-01,Point(1 1)@2019-09-05}')), + (tpss, timedelta(hours=12), + TGeomPointSeq('{Point(1 1)@2019-09-01, Point(1.5 1.5)@2019-09-01 12:00:00,' + 'Point(2 2)@2019-09-02, Point(1 1)@2019-09-03, Point(1 1)@2019-09-03 12:00:00, ' + 'Point(1 1)@2019-09-04, Point(1 1)@2019-09-04 12:00:00, Point(1 1)@2019-09-05}')), + ], + ids=['Instant days', 'Instant hours', + 'Discrete Sequence days', 'Discrete Sequence hours', + 'Sequence days', 'Sequence hours', + 'Sequence Set days', 'Sequence Set hours' + ] ) - def test_to_sequence(self, temporal, expected): - temp = temporal.to_sequence() - assert isinstance(temp, TGeomPointSeq) - assert temp == expected + def test_temporal_sample(self, tpoint, delta, expected): + assert tpoint.temporal_sample(delta) == expected @pytest.mark.parametrize( - 'temporal, expected', - [ - (TGeomPointInst('Point(1 1)@2019-09-01'), - TGeomPointSeqSet('{[Point(1 1)@2019-09-01]}')), - (TGeomPointSeq('{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}'), - TGeomPointSeqSet('{[Point(1 1)@2019-09-01], [Point(2 2)@2019-09-02]}')), - (TGeomPointSeq('[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]'), - TGeomPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}')), - (TGeomPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}'), - TGeomPointSeqSet('{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}')), - ], - ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + 'tpoint, delta, expected', + [(tps, timedelta(days=4), None), + (tps, timedelta(hours=12), None), + (tpss, timedelta(days=4), None), + (tpss, timedelta(hours=12), + TGeomPointSeq('[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]')), + ], + ids=['Sequence days', 'Sequence hours', + 'Sequence Set days', 'Sequence Set hours'] ) - def test_to_sequenceset(self, temporal, expected): - temp = temporal.to_sequenceset() - assert isinstance(temp, TGeomPointSeqSet) - assert temp == expected + def test_stops(self, tpoint, delta, expected): + assert tpoint.stops(0.0, delta) == expected @pytest.mark.parametrize( 'temporal, expected', diff --git a/pymeos/tests/main/tint_test.py b/pymeos/tests/main/tint_test.py index 28a29281..7dadfdf1 100644 --- a/pymeos/tests/main/tint_test.py +++ b/pymeos/tests/main/tint_test.py @@ -5,8 +5,10 @@ import pytest -from pymeos import TBool, TBoolInst, TBoolSeq, TBoolSeqSet, TFloat, TFloatInst, TFloatSeq, TFloatSeqSet, TInt, \ - TIntInst, TIntSeq, TIntSeqSet, TInterpolation, TBox, TimestampSet, Period, PeriodSet +from pymeos import TBool, TBoolInst, TBoolSeq, TBoolSeqSet, \ + TFloat, TFloatInst, TFloatSeq, TFloatSeqSet, \ + TInt, TIntInst, TIntSeq, TIntSeqSet, \ + TInterpolation, TBox, TimestampSet, Period, PeriodSet from tests.conftest import TestPyMEOS @@ -340,12 +342,47 @@ def test_as_mfjson(self, temporal, expected): assert temporal.as_mfjson() == expected +class TestTIntConversions(TestTInt): + tii = TIntInst('1@2019-09-01') + tids = TIntSeq('{1@2019-09-01, 2@2019-09-02}') + tis = TIntSeq('[1@2019-09-01, 2@2019-09-02]') + tiss = TIntSeqSet('{[1@2019-09-01, 2@2019-09-02],[1@2019-09-03, 1@2019-09-05]}') + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tii, TFloatInst('1@2019-09-01')), + (tids, TFloatSeq('{1@2019-09-01,2@2019-09-02}')), + (tis, TFloatSeq('Interp=Step;[1@2019-09-01,2@2019-09-02]')), + (tiss, TFloatSeq('Interp=Step;{[1@2019-09-01,2@2019-09-02],[1@2019-09-03,1@2019-09-05]}')), + ], + ids=['Instant', 'Discrete Sequence', 'Step Sequence', 'Step Sequence Set'] + ) + def test_to_tfloat(self, temporal, expected): + temp = temporal.to_tfloat() + assert isinstance(temp, TFloat) + assert temp == expected + + class TestTIntAccessors(TestTInt): tii = TIntInst('1@2019-09-01') tids = TIntSeq('{1@2019-09-01, 2@2019-09-02}') tis = TIntSeq('[1@2019-09-01, 2@2019-09-02]') tiss = TIntSeqSet('{[1@2019-09-01, 2@2019-09-02],[1@2019-09-03, 1@2019-09-05]}') + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tii, TBox('TBOXINT XT([1,1],[2019-09-01, 2019-09-01])')), + (tids, TBox('TBOXINT XT([1,2],[2019-09-01, 2019-09-02])')), + (tis, TBox('TBOXINT XT([1,2],[2019-09-01, 2019-09-02])')), + (tiss, TBox('TBOXINT XT([1,2],[2019-09-01, 2019-09-05])')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_bounding_box(self, temporal, expected): + assert temporal.bounding_box() == expected + @pytest.mark.parametrize( 'temporal, expected', [ @@ -385,6 +422,32 @@ def test_value_set(self, temporal, expected): def test_values(self, temporal, expected): assert temporal.values() == expected + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tii, intrange(1, 1, True, True)), + (tids, intrange(1, 2, True, True)), + (tis, intrange(1, 2, True, True)), + (tiss, intrange(1, 2, True, True)), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_value_range(self, temporal, expected): + assert temporal.value_range() == expected + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tii, [intrange(1, 1, True, True)]), + (tids, [intrange(1, 2, True, True)]), + (tis, [intrange(1, 2, True, True)]), + (tiss, [intrange(1, 2, True, True)]), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_value_ranges(self, temporal, expected): + assert temporal.value_ranges() == expected + @pytest.mark.parametrize( 'temporal, expected', [ @@ -558,27 +621,27 @@ def test_end_instant(self, temporal, expected): 'temporal, expected', [ (tii, tii), - (tids, TIntInst('2@2019-09-02')), - (tis, TIntInst('2@2019-09-02')), - (tiss, TIntInst('2@2019-09-02')), + (tids, tii), + (tis, tii), + (tiss, tii), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_max_instant(self, temporal, expected): - assert temporal.max_instant() == expected + def test_min_instant(self, temporal, expected): + assert temporal.min_instant() == expected @pytest.mark.parametrize( 'temporal, expected', [ (tii, tii), - (tids, tii), - (tis, tii), - (tiss, tii), + (tids, TIntInst('2@2019-09-02')), + (tis, TIntInst('2@2019-09-02')), + (tiss, TIntInst('2@2019-09-02')), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_min_instant(self, temporal, expected): - assert temporal.min_instant() == expected + def test_max_instant(self, temporal, expected): + assert temporal.max_instant() == expected @pytest.mark.parametrize( 'temporal, n, expected', @@ -692,6 +755,23 @@ def test_timestamps(self, temporal, expected): def test_segments(self, temporal, expected): assert temporal.segments() == expected + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tii, 440045287), + (tids, 3589664982), + (tis, 3589664982), + (tiss, 205124107) + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_hash(self, temporal, expected): + assert hash(temporal) == expected + + def test_value_timestamp(self): + assert self.tii.value() == 1 + assert self.tii.timestamp() == datetime(year=2019, month=9, day=1, tzinfo=timezone.utc) + @pytest.mark.parametrize( 'temporal, expected', [ @@ -704,31 +784,42 @@ def test_lower_upper_inc(self, temporal, expected): assert temporal.lower_inc() == expected assert temporal.upper_inc() == expected + def test_sequenceset_sequence_functions(self): + tiss1 =TIntSeqSet('{[1@2019-09-01, 2@2019-09-02],' + '[1@2019-09-03, 1@2019-09-05], [3@2019-09-06]}') + assert tiss1.num_sequences() == 3 + assert tiss1.start_sequence() == TIntSeq('[1@2019-09-01, 2@2019-09-02]') + assert tiss1.end_sequence() == TIntSeq('[3@2019-09-06]') + assert tiss1.sequence_n(1) == TIntSeq('[1@2019-09-03, 1@2019-09-05]') + assert tiss1.sequences() == [TIntSeq('[1@2019-09-01, 2@2019-09-02]'), + TIntSeq('[1@2019-09-03, 1@2019-09-05]'), + TIntSeq('[3@2019-09-06]')] + @pytest.mark.parametrize( 'temporal, expected', [ - (tii, 440045287), - (tids, 3589664982), - (tis, 3589664982), - (tiss, 205124107) + (tii, 0), + (tids, 0), + (tis, 86400000000), + (tiss, 259200000000), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_hash(self, temporal, expected): - assert hash(temporal) == expected + def test_integral(self, temporal, expected): + assert temporal.integral() == expected @pytest.mark.parametrize( 'temporal, expected', [ - (tii, TBox('TBOX XT([1,1],[2019-09-01, 2019-09-01])')), - (tids, TBox('TBOX XT([1,2],[2019-09-01, 2019-09-02])')), - (tis, TBox('TBOX XT([1,2],[2019-09-01, 2019-09-02])')), - (tiss, TBox('TBOX XT([1,2],[2019-09-01, 2019-09-05])')), + (tii, 1), + (tids, 1.5), + (tis, 1), + (tiss, 1), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_bounding_box(self, temporal, expected): - assert temporal.bounding_box() == expected + def test_time_weighted_average(self, temporal, expected): + assert temporal.time_weighted_average() == expected class TestTIntTransformations(TestTInt): @@ -737,6 +828,9 @@ class TestTIntTransformations(TestTInt): tis = TIntSeq('[1@2019-09-01, 2@2019-09-02]') tiss = TIntSeqSet('{[1@2019-09-01, 2@2019-09-02],[1@2019-09-03, 1@2019-09-05]}') + tis_d = TIntSeq('[1@2019-09-01]') + tiss_d = TIntSeqSet('{[1@2019-09-01],[2@2019-09-03]}') + @pytest.mark.parametrize( 'temporal, expected', [ @@ -790,6 +884,30 @@ def test_to_sequenceset(self, temporal, expected): assert isinstance(temp, TIntSeqSet) assert temp == expected + @pytest.mark.parametrize( + 'temporal, interpolation, expected', + [ + (tii, TInterpolation.DISCRETE, + TIntSeq('{1@2019-09-01}')), + (tids, TInterpolation.DISCRETE, tids), + (tis_d, TInterpolation.DISCRETE, + TIntSeq('{1@2019-09-01}')), + (tiss_d, TInterpolation.DISCRETE, + TIntSeq('{1@2019-09-01,2@2019-09-03}')), + + (tii, TInterpolation.STEPWISE, + TIntSeq('[1@2019-09-01]')), + (tids, TInterpolation.STEPWISE, + TIntSeqSet('{[1@2019-09-01], [2@2019-09-02]}')), + (tis, TInterpolation.STEPWISE, tis), + (tiss, TInterpolation.STEPWISE, tiss), + ], + ids=['Instant to discrete', 'Discrete Sequence to discrete', 'Sequence to discrete', 'SequenceSet to discrete', + 'Instant to step', 'Discrete Sequence to step', 'Sequence to step', 'SequenceSet to step'] + ) + def test_set_interpolation(self, temporal, interpolation, expected): + assert temporal.set_interpolation(interpolation) == expected + @pytest.mark.parametrize( 'tint, delta, expected', [(tii, timedelta(days=4), TIntInst('1@2019-09-05')), @@ -854,32 +972,42 @@ def test_shift_tscale(self): TIntSeqSet('{[1@2019-09-05 00:00:00, 2@2019-09-05 00:30:00],' '[1@2019-09-05 01:00:00, 1@2019-09-05 02:00:00]}') + @pytest.mark.parametrize( + 'tint, delta, expected', + [(tii, timedelta(days=4), TIntInst('1@2019-09-01')), + (tii, timedelta(hours=12), TIntInst('1@2019-09-01')), + (tids, timedelta(days=4), TIntSeq('{1@2019-09-01}')), + (tids, timedelta(hours=12), TIntSeq('{1@2019-09-01, 2@2019-09-02}')), + (tis, timedelta(days=4), TIntSeq('{1@2019-09-01}')), + (tis, timedelta(hours=12), TIntSeq('{1@2019-09-01, 1@2019-09-01 12:00:00, 2@2019-09-02}')), + (tiss, timedelta(days=4), + TIntSeq('{1@2019-09-01,1@2019-09-05}')), + (tiss, timedelta(hours=12), + TIntSeq('{1@2019-09-01, 1@2019-09-01 12:00:00, 2@2019-09-02,' + '1@2019-09-03, 1@2019-09-03 12:00:00, 1@2019-09-04, ' + '1@2019-09-04 12:00:00, 1@2019-09-05}')), + ], + ids=['Instant days', 'Instant hours', + 'Discrete Sequence days', 'Discrete Sequence hours', + 'Sequence days', 'Sequence hours', + 'Sequence Set days', 'Sequence Set hours'] + ) + def test_temporal_sample(self, tint, delta, expected): + assert tint.temporal_sample(delta) == expected + @pytest.mark.parametrize( 'temporal, expected', [ (tii, TFloatInst('1@2019-09-01')), (tids, TFloatSeq('{1@2019-09-01, 2@2019-09-02}')), (tis, TFloatSeq('Interp=Step;[1@2019-09-01, 2@2019-09-02]')), - # (tiss, TFloatSeqSet('Interp=Step;{[1@2019-09-01, 2@2019-09-02],[1@2019-09-03, 1@2019-09-05]}')), + (tiss, TFloatSeqSet('Interp=Step;{[1@2019-09-01, 2@2019-09-02],[1@2019-09-03, 1@2019-09-05]}')), ], - ids=['Instant', 'Discrete Sequence', 'Sequence'] #, 'SequenceSet'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_to_tfloat(self, temporal, expected): assert temporal.to_tfloat() == expected - @pytest.mark.parametrize( - 'temporal, expected', - [ - (tii, intrange(1, 1, True, True)), - (tids, intrange(1, 2, True, True)), - (tis, intrange(1, 2, True, True)), - (tiss, intrange(1, 2, True, True)), - ], - ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] - ) - def test_to_intrange(self, temporal, expected): - assert temporal.to_intrange() == expected - class TestTIntModifications(TestTInt): tii = TIntInst('1@2019-09-01') @@ -966,7 +1094,6 @@ class TestTIntMathematicalOperations(TestTInt): tis = TIntSeq('[1@2019-09-01, 2@2019-09-02]') tiss = TIntSeqSet('{[1@2019-09-01, 2@2019-09-02],[1@2019-09-03, 1@2019-09-05]}') tintarg = TIntSeq('[2@2019-09-01, 1@2019-09-02, 1@2019-09-03]') - tfloatarg = TFloatSeq('[2@2019-09-01, 1@2019-09-02, 1@2019-09-03]') @pytest.mark.parametrize( 'temporal, argument, expected', @@ -975,13 +1102,8 @@ class TestTIntMathematicalOperations(TestTInt): (tids, tintarg, TIntSeq('{3@2019-09-01, 3@2019-09-02}')), (tis, tintarg, TIntSeq('[3@2019-09-01, 3@2019-09-02]')), (tiss, tintarg, TIntSeqSet('{[3@2019-09-01, 3@2019-09-02],[2@2019-09-03]}')), - (tii, tfloatarg, TFloatInst('3@2019-09-01')), - (tids, tfloatarg, TFloatSeq('{3@2019-09-01, 3@2019-09-02}')), - (tis, tfloatarg, TFloatSeqSet('{[3@2019-09-01, 2@2019-09-02),[3@2019-09-02]}')), - (tiss, tfloatarg, TFloatSeqSet('{[3@2019-09-01, 2@2019-09-02),[3@2019-09-02],[2@2019-09-03]}')), ], - ids=['Instant TInt', 'Discrete Sequence TInt', 'Sequence TInt', 'SequenceSet TInt', - 'Instant TFloat', 'Discrete Sequence TFloat', 'Sequence TFloat', 'SequenceSet TFloat'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_temporal_add_temporal(self, temporal, argument, expected): assert temporal.add(argument) == expected @@ -999,13 +1121,9 @@ def test_temporal_add_temporal(self, temporal, argument, expected): ) def test_temporal_add_int_float(self, temporal, argument, expected): assert temporal.add(argument) == expected - assert temporal.add(float(argument)) == expected.to_tfloat() assert temporal.radd(argument) == expected - assert temporal.radd(float(argument)) == expected.to_tfloat() assert (temporal + argument) == expected - assert (temporal + float(argument)) == expected.to_tfloat() assert (argument + temporal) == expected - assert (float(argument) + temporal) == expected.to_tfloat() @pytest.mark.parametrize( 'temporal, argument, expected', @@ -1014,13 +1132,8 @@ def test_temporal_add_int_float(self, temporal, argument, expected): (tids, tintarg, TIntSeq('{-1@2019-09-01, 1@2019-09-02}')), (tis, tintarg, TIntSeq('[-1@2019-09-01, 1@2019-09-02]')), (tiss, tintarg, TIntSeqSet('{[-1@2019-09-01, 1@2019-09-02],[0@2019-09-03]}')), - (tii, tfloatarg, TFloatInst('-1@2019-09-01')), - (tids, tfloatarg, TFloatSeq('{-1@2019-09-01, 1@2019-09-02}')), - (tis, tfloatarg, TFloatSeqSet('{[-1@2019-09-01, 0@2019-09-02),[1@2019-09-02]}')), - (tiss, tfloatarg, TFloatSeqSet('{[-1@2019-09-01, 0@2019-09-02),[1@2019-09-02],[0@2019-09-03]}')) ], - ids=['Instant TInt', 'Discrete Sequence TInt', 'Sequence TInt', 'SequenceSet TInt', - 'Instant TFloat', 'Discrete Sequence TFloat', 'Sequence TFloat', 'SequenceSet TFloat'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_temporal_sub_temporal(self, temporal, argument, expected): assert temporal.sub(argument) == expected @@ -1038,13 +1151,9 @@ def test_temporal_sub_temporal(self, temporal, argument, expected): ) def test_temporal_sub_int_float(self, temporal, argument, expected): assert temporal.sub(argument) == expected - assert temporal.sub(float(argument)) == expected.to_tfloat() assert temporal.rsub(argument) == -1 * expected - assert temporal.rsub(float(argument)) == (-1 * expected).to_tfloat() assert (temporal - argument) == expected - assert (temporal - float(argument)) == expected.to_tfloat() assert (argument - temporal) == - 1 * expected - assert (float(argument) - temporal) == (- 1 * expected).to_tfloat() @pytest.mark.parametrize( 'temporal, argument, expected', @@ -1053,13 +1162,8 @@ def test_temporal_sub_int_float(self, temporal, argument, expected): (tids, tintarg, TIntSeq('{2@2019-09-01, 2@2019-09-02}')), (tis, tintarg, TIntSeq('[2@2019-09-01, 2@2019-09-02]')), (tiss, tintarg, TIntSeqSet('{[2@2019-09-01, 2@2019-09-02],[1@2019-09-03]}')), - (tii, tfloatarg, TFloatInst('2@2019-09-01')), - (tids, tfloatarg, TFloatSeq('{2@2019-09-01, 2@2019-09-02}')), - (tis, tfloatarg, TFloatSeqSet('{[2@2019-09-01, 1@2019-09-02), [2@2019-09-02]}')), - (tiss, tfloatarg, TFloatSeqSet('{[2@2019-09-01, 1@2019-09-02), [2@2019-09-02],[1@2019-09-03]}')), ], - ids=['Instant TInt', 'Discrete Sequence TInt', 'Sequence TInt', 'SequenceSet TInt', - 'Instant TFloat', 'Discrete Sequence TFloat', 'Sequence TFloat', 'SequenceSet TFloat'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_temporal_mul_temporal(self, temporal, argument, expected): assert temporal.mul(argument) == expected @@ -1089,13 +1193,9 @@ def test_temporal_mul_temporal(self, temporal, argument, expected): ) def test_temporal_mul_int_float(self, temporal, argument, expected): assert temporal.mul(argument) == expected - assert temporal.mul(float(argument)) == expected.to_tfloat() assert temporal.rmul(argument) == expected - assert temporal.rmul(float(argument)) == expected.to_tfloat() assert (temporal * argument) == expected - assert (temporal * float(argument)) == expected.to_tfloat() assert (argument * temporal) == expected - assert (float(argument) * temporal) == expected.to_tfloat() @pytest.mark.parametrize( 'temporal, argument, expected', @@ -1104,13 +1204,8 @@ def test_temporal_mul_int_float(self, temporal, argument, expected): (tids, tintarg, TIntSeq('{0@2019-09-01, 2@2019-09-02}')), (tis, tintarg, TIntSeq('[0@2019-09-01, 2@2019-09-02]')), (tiss, tintarg, TIntSeqSet('{[0@2019-09-01, 2@2019-09-02],[1@2019-09-03]}')), - (tii, tfloatarg, TFloatInst('0.5@2019-09-01')), - (tids, tfloatarg, TFloatSeq('{0.5@2019-09-01, 2@2019-09-02}')), - (tis, tfloatarg, TFloatSeqSet('{[0.5@2019-09-01, 1@2019-09-02), [2@2019-09-02]}')), - (tiss, tfloatarg, TFloatSeqSet('{[0.5@2019-09-01, 1@2019-09-02), [2@2019-09-02],[1@2019-09-03]}')) ], - ids=['Instant TInt', 'Discrete Sequence TInt', 'Sequence TInt', 'SequenceSet TInt', - 'Instant TFloat', 'Discrete Sequence TFloat', 'Sequence TFloat', 'SequenceSet TFloat'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_temporal_div_temporal(self, temporal, argument, expected): assert temporal.div(argument) == expected @@ -1123,23 +1218,13 @@ def test_temporal_div_temporal(self, temporal, argument, expected): (tids, 1, tids), (tis, 1, tis), (tiss, 1, tiss), - (tii, 1.0, TFloatInst('1@2019-09-01')), - (tids, 1.0, TFloatSeq('{1@2019-09-01, 2@2019-09-02}')), - # (tis, 1.0, TFloatSeq('[1@2019-09-01, 2@2019-09-02]')), - # (tiss, 1.0, TFloatSeqSet('{[1@2019-09-01, 2@2019-09-02],[1@2019-09-03, 1@2019-09-05]}')), (tii, 2, TIntInst('0@2019-09-01')), (tids, 2, TIntSeq('{0@2019-09-01, 1@2019-09-02}')), (tis, 2, TIntSeq('[0@2019-09-01, 1@2019-09-02]')), (tiss, 2, TIntSeqSet('{[0@2019-09-01, 1@2019-09-02],[0@2019-09-03, 0@2019-09-05]}')), - (tii, 2.0, TFloatInst('0.5@2019-09-01')), - (tids, 2.0, TFloatSeq('{0.5@2019-09-01, 1@2019-09-02}')), - (tis, 2.0, TFloatSeq('Interp=Step;[0.5@2019-09-01, 1@2019-09-02]')), - (tiss, 2.0, TFloatSeqSet('Interp=Step;{[0.5@2019-09-01, 1@2019-09-02],[0.5@2019-09-03, 0.5@2019-09-05]}')), ], ids=['Instant 1', 'Discrete Sequence 1', 'Sequence 1', 'SequenceSet 1', - 'Instant 1.0', 'Discrete Sequence 1.0', # 'Sequence 1.0', 'SequenceSet 1.0', - 'Instant 2', 'Discrete Sequence 2', 'Sequence 2', 'SequenceSet 2', - 'Instant 2.0', 'Discrete Sequence 2.0', 'Sequence 2.0', 'SequenceSet 2.0'] + 'Instant 2', 'Discrete Sequence 2', 'Sequence 2', 'SequenceSet 2'] ) def test_temporal_div_int_float (self, temporal, argument, expected): assert temporal.div(argument) == expected @@ -1157,16 +1242,18 @@ def test_abs(self, temporal): @pytest.mark.parametrize( 'temporal, expected', [ - # (tii, TIntInst('1@2019-09-01')), + (tii, None), (tids, TIntSeq('{1@2019-09-01, 1@2019-09-02}')), (tis, TIntSeq('[1@2019-09-01, 1@2019-09-02)')), (tiss, TIntSeqSet('{[1@2019-09-01, 1@2019-09-02),[0@2019-09-03, 0@2019-09-05)}')), ], - ids=[# 'Instant', - 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) def test_delta_value(self, temporal, expected): - assert temporal.delta_value() == expected + if expected is None: + assert temporal.delta_value() is None + else: + assert temporal.delta_value() == expected class TestTIntRestrictors(TestTInt): @@ -1187,47 +1274,77 @@ class TestTIntRestrictors(TestTInt): (tii, timestamp_set, TIntInst('1@2019-09-01')), (tii, period, TIntInst('1@2019-09-01')), (tii, period_set, TIntInst('1@2019-09-01')), - (tii, 1, TIntInst('1@2019-09-01')), - (tii, 2, None), - # (tii, [1,2], TIntInst('1@2019-09-01')), (tids, timestamp, TIntSeq('{1@2019-09-01}')), (tids, timestamp_set, TIntSeq('{1@2019-09-01}')), (tids, period, TIntSeq('{1@2019-09-01, 2@2019-09-02}')), (tids, period_set, TIntSeq('{1@2019-09-01, 2@2019-09-02}')), - (tids, 1, TIntSeq('{1@2019-09-01}')), - (tids, 2, TIntSeq('{2@2019-09-02}')), - # (tids, [1,2], TIntSeq('{2@2019-09-02}')), (tis, timestamp, TIntSeq('[1@2019-09-01]')), (tis, timestamp_set, TIntSeq('{1@2019-09-01}')), (tis, period, TIntSeq('[1@2019-09-01, 2@2019-09-02]')), (tis, period_set, TIntSeq('[1@2019-09-01, 2@2019-09-02]')), - (tis, 1, TIntSeq('[1@2019-09-01, 1@2019-09-02)')), - (tis, 2, TIntSeq('[2@2019-09-02]')), - # (tis, [1,2], TIntSeq('[2@2019-09-02]')), (tiss, timestamp, TIntSeqSet('[1@2019-09-01]')), (tiss, timestamp_set, TIntSeq('{1@2019-09-01, 1@2019-09-03}')), (tiss, period, TIntSeqSet('{[1@2019-09-01, 2@2019-09-02]}')), (tiss, period_set, TIntSeqSet('{[1@2019-09-01, 2@2019-09-02],[1@2019-09-03, 1@2019-09-05]}')), - (tiss, 1, TIntSeqSet('{[1@2019-09-01, 1@2019-09-02),[1@2019-09-03, 1@2019-09-05]}')), - (tiss, 2, TIntSeqSet('{[2@2019-09-02]}')), - # (tiss, [1,2], TIntSeqSet('{[2@2019-09-02]}')) ], ids=['Instant-Timestamp', 'Instant-TimestampSet', 'Instant-Period', - 'Instant-PeriodSet', 'Instant-1', 'Instant-2', # 'Instant-[1,2]', + 'Instant-PeriodSet', 'Discrete Sequence-Timestamp', 'Discrete Sequence-TimestampSet', 'Discrete Sequence-Period', 'Discrete Sequence-PeriodSet', - 'Discrete Sequence-1', 'Discrete Sequence-2', # 'Discrete Sequence-[1,2]', 'Sequence-Timestamp', 'Sequence-TimestampSet', 'Sequence-Period', - 'Sequence-PeriodSet', 'Sequence-1', 'Sequence-2', # 'Sequence-[1,2]', - 'SequenceSet-Timestamp', 'SequenceSet-TimestampSet', 'SequenceSet-Period', - 'SequenceSet-PeriodSet', 'SequenceSet-1', 'SequenceSet-2', # 'SequenceSet-[1,2]' + 'Sequence-PeriodSet', + 'SequenceSet-Timestamp', 'SequenceSet-TimestampSet', + 'SequenceSet-Period', 'SequenceSet-PeriodSet', ] ) - def test_at(self, temporal, restrictor, expected): + def test_at_time(self, temporal, restrictor, expected): + assert temporal.at(restrictor) == expected + + @pytest.mark.parametrize( + 'temporal, restrictor, expected', + [ + (tii, 1, TIntInst('1@2019-09-01')), + (tii, 2, None), + (tii, intrange(1, 1, True, True), TIntInst('1@2019-09-01')), + # (tii, [1,2], TIntInst('1@2019-09-01')), + # (tii, [intrange(1, 1, True, True), intrange(2, 2, True, True)], + # TIntInst('1@2019-09-01')), + + (tids, 1, TIntSeq('{1@2019-09-01}')), + (tids, 2, TIntSeq('{2@2019-09-02}')), + (tids, intrange(1, 1, True, True), TIntSeq('{1@2019-09-01}')), + # (tids, [1,2], TIntSeq('{2@2019-09-02}')), + # (tids, [intrange(1, 1, True, True), tids), + + (tis, 1, TIntSeq('[1@2019-09-01, 1@2019-09-02)')), + (tis, 2, TIntSeq('[2@2019-09-02]')), + (tis, intrange(1, 1, True, True), TIntSeq('[1@2019-09-01, 1@2019-09-02)')), + # (tis, [1,2], TIntSeq('[2@2019-09-02]')), + # (tis, [intrange(1, 1, True, True), intrange(2, 2, True, True)], + # TIntSeqSet('{[1@2019-09-01, 2@2019-09-02]}')), + + (tiss, 1, TIntSeqSet('{[1@2019-09-01, 1@2019-09-02),[1@2019-09-03, 1@2019-09-05]}')), + (tiss, 2, TIntSeqSet('{[2@2019-09-02]}')), + (tiss, intrange(1, 1, True, True), TIntSeqSet('{[1@2019-09-01, 1@2019-09-02),[1@2019-09-03, 1@2019-09-05]}')), + # (tiss, [1,2], TIntSeqSet('{[2@2019-09-02]}')) + # (tiss, [intrange(1, 1, True, True), intrange(2, 2, True, True)], + # tiss), + ], + ids=['Instant-1', 'Instant-2', 'Instant-Range', + # 'Instant-ValueList', 'Instant-RangeList', + 'Discrete Sequence-1', 'Discrete Sequence-2', 'Discrete Sequence-Range', + # 'Discrete Sequence-ValueList', 'Discrete Sequence-RangeList', + 'Sequence-1', 'Sequence-2', 'Sequence-Range', + # 'Sequence-ValueList', 'Sequence-RangeList', + 'SequenceSet-1', 'SequenceSet-2', 'SequenceSet-Range', + # 'SequenceSet-ValueList', 'SequenceSet-RangeList' + ] + ) + def test_at_values(self, temporal, restrictor, expected): assert temporal.at(restrictor) == expected @pytest.mark.parametrize( @@ -1264,25 +1381,16 @@ def test_at_max(self, temporal, expected): (tii, timestamp_set, None), (tii, period, None), (tii, period_set, None), - (tii, 1, None), - (tii, 2, TIntInst('1@2019-09-01')), - # (tii, [1,2], None), (tids, timestamp, TIntSeq('{2@2019-09-02}')), (tids, timestamp_set, TIntSeq('{2@2019-09-02}')), (tids, period, None), (tids, period_set, None), - (tids, 1, TIntSeq('{2@2019-09-02}')), - (tids, 2, TIntSeq('{1@2019-09-01}')), - # (tids, [1,2], tids), (tis, timestamp, TIntSeqSet('{(1@2019-09-01, 2@2019-09-02]}')), (tis, timestamp_set, TIntSeqSet('{(1@2019-09-01, 2@2019-09-02]}')), (tis, period, None), (tis, period_set, None), - (tis, 1, TIntSeqSet('{[2@2019-09-02]}')), - (tis, 2, TIntSeqSet('{[1@2019-09-01, 1@2019-09-02)}')), - # (tis, [1,2], tis), (tiss, timestamp, TIntSeqSet('{(1@2019-09-01, 2@2019-09-02],[1@2019-09-03, 1@2019-09-05]}')), @@ -1290,22 +1398,62 @@ def test_at_max(self, temporal, expected): TIntSeqSet('{(1@2019-09-01, 2@2019-09-02],(1@2019-09-03, 1@2019-09-05]}')), (tiss, period, TIntSeqSet('{[1@2019-09-03, 1@2019-09-05]}')), (tiss, period_set, None), - (tiss, 1, TIntSeqSet('{[2@2019-09-02]}')), - (tiss, 2, TIntSeqSet('{[1@2019-09-01, 1@2019-09-02),[1@2019-09-03, 1@2019-09-05]}')), - # (tiss, [1,2], tiss) ], ids=['Instant-Timestamp', 'Instant-TimestampSet', 'Instant-Period', - 'Instant-PeriodSet', 'Instant-1', 'Instant-2', # 'Instant-[1,2]', + 'Instant-PeriodSet', 'Discrete Sequence-Timestamp', 'Discrete Sequence-TimestampSet', 'Discrete Sequence-Period', 'Discrete Sequence-PeriodSet', - 'Discrete Sequence-1', 'Discrete Sequence-2', # 'Discrete Sequence-[1,2]', 'Sequence-Timestamp', 'Sequence-TimestampSet', 'Sequence-Period', - 'Sequence-PeriodSet', 'Sequence-1', 'Sequence-2', # 'Sequence-[1,2]', + 'Sequence-PeriodSet', 'SequenceSet-Timestamp', 'SequenceSet-TimestampSet', 'SequenceSet-Period', - 'SequenceSet-PeriodSet', 'SequenceSet-1', 'SequenceSet-2', # 'SequenceSet-[1,2]' + 'SequenceSet-PeriodSet', + ] + ) + def test_minus_time(self, temporal, restrictor, expected): + assert temporal.minus(restrictor) == expected + + @pytest.mark.parametrize( + 'temporal, restrictor, expected', + [ + (tii, 1, None), + (tii, 2, TIntInst('1@2019-09-01')), + (tii, intrange(1, 1, True, True), None), + # (tii, [1,2], None), + # (tii, [intrange(1, 1, True, True), intrange(2, 2, True, True)], + # None), + + (tids, 1, TIntSeq('{2@2019-09-02}')), + (tids, 2, TIntSeq('{1@2019-09-01}')), + (tids, intrange(1, 1, True, True), TIntSeq('{2@2019-09-02}')), + # (tids, [1,2], tids), + # (tids, [intrange(1, 1, True, True), intrange(2, 2, True, True)], + # None), + + (tis, 1, TIntSeqSet('{[2@2019-09-02]}')), + (tis, 2, TIntSeqSet('{[1@2019-09-01, 1@2019-09-02)}')), + (tis, intrange(1, 1, True, True), TIntSeqSet('{[2@2019-09-02]}')), + # (tis, [1,2], tis), + # (tis, [intrange(1, 1, True, True), intrange(2, 2, True, True)], + # None), + + (tiss, 1, TIntSeqSet('{[2@2019-09-02]}')), + (tiss, 2, TIntSeqSet('{[1@2019-09-01, 1@2019-09-02),[1@2019-09-03, 1@2019-09-05]}')), + (tis, intrange(1, 1, True, True), TIntSeqSet('{[2@2019-09-02]}')), + # (tiss, [1,2], tiss) + # (tiss, [intrange(1, 1, True, True), intrange(2, 2, True, True)], + # None), + ], + ids=['Instant-1', 'Instant-2', 'Instant-Range', + # 'Instant-ValueList', 'Instant-RangeList', + 'Discrete Sequence-1', 'Discrete Sequence-2', 'Discrete Sequence-Range', + # 'Discrete Sequence-ValueList', 'Discrete Sequence-RangeList', + 'Sequence-1', 'Sequence-2', 'Sequence-Range', + # 'Sequence-ValueList', 'Sequence-RangeList', + 'SequenceSet-1', 'SequenceSet-2', 'SequenceSet-Range', + # 'SequenceSet-ValueList', 'SequenceSet-RangeList', ] ) - def test_minus(self, temporal, restrictor, expected): + def test_minus_values(self, temporal, restrictor, expected): assert temporal.minus(restrictor) == expected @pytest.mark.parametrize( @@ -1393,24 +1541,23 @@ class TestTIntTopologicalFunctions(TestTInt): tis = TIntSeq('[1@2019-09-01, 2@2019-09-02]') tiss = TIntSeqSet('{[1@2019-09-01, 2@2019-09-02], [1@2019-09-03, 1@2019-09-05]}') - # Problem in MEOS: the definition of TBox for tint should have an intspan ! - # @pytest.mark.parametrize( - # 'temporal, argument, expected', - # [ - # (tii, TIntInst('1@2019-09-02'), False), - # (tii, TIntSeq('(1@2019-09-01, 2@2019-09-02]'), True), - # (tids, TIntInst('1@2019-09-03'), False), - # (tids, TIntInst('2@2019-09-01'), True), - # (tis, TIntInst('1@2019-09-03'), False), - # (tis, TIntSeq('(2@2019-09-01, 3@2019-09-02]'), True), - # (tiss, TIntInst('1@2019-09-08'), False), - # (tiss, TIntSeq('(2@2019-09-01, 3@2019-09-02]'), True), - # ], - # ids=['Instant False', 'Instant True', 'Discrete Sequence False', 'Discrete Sequence True', - # 'Sequence False', 'Sequence True', 'Sequence Set False', 'Sequence Set True'] - # ) - # def test_is_adjacent(self, temporal, argument, expected): - # assert temporal.is_adjacent(argument) == expected + @pytest.mark.parametrize( + 'temporal, argument, expected', + [ + (tii, TIntInst('1@2019-09-02'), False), + (tii, TIntInst('2@2019-09-02'), True), + (tids, TIntInst('1@2019-09-03'), False), + (tids, TIntInst('3@2019-09-02'), True), + (tis, TIntInst('1@2019-09-03'), False), + (tis, TIntInst('3@2019-09-02'), True), + (tiss, TIntInst('1@2019-09-08'), False), + (tiss, TIntInst('3@2019-09-02'), True), + ], + ids=['Instant False', 'Instant True', 'Discrete Sequence False', 'Discrete Sequence True', + 'Sequence False', 'Sequence True', 'Sequence Set False', 'Sequence Set True'] + ) + def test_is_adjacent(self, temporal, argument, expected): + assert temporal.is_adjacent(argument) == expected @pytest.mark.parametrize( 'temporal, argument, expected', @@ -1773,7 +1920,7 @@ def test_ever_equal_always_not_equal(self, temporal, argument, expected): ) def test_always_less_ever_greater_or_equal(self, temporal, argument, expected): assert temporal.always_less(argument) == expected - # assert temporal.never_greater_or_equal(argument) == expected + assert temporal.never_greater_or_equal(argument) == expected assert temporal.ever_greater_or_equal(argument) == not_(expected) @pytest.mark.parametrize( diff --git a/pymeos/tests/main/ttext_test.py b/pymeos/tests/main/ttext_test.py index 22da37c7..20df2c0c 100644 --- a/pymeos/tests/main/ttext_test.py +++ b/pymeos/tests/main/ttext_test.py @@ -325,6 +325,19 @@ class TestTTextAccessors(TestTText): tts = TTextSeq('[AAA@2019-09-01, BBB@2019-09-02]') ttss = TTextSeqSet('{[AAA@2019-09-01, BBB@2019-09-02],[AAA@2019-09-03, AAA@2019-09-05]}') + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tti, Period('[2019-09-01, 2019-09-01]')), + (ttds, Period('[2019-09-01, 2019-09-02]')), + (tts, Period('[2019-09-01, 2019-09-02]')), + (ttss, Period('[2019-09-01, 2019-09-05]')), + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_bounding_box(self, temporal, expected): + assert temporal.bounding_box() == expected + @pytest.mark.parametrize( 'temporal, expected', [ @@ -416,18 +429,18 @@ def test_min_value(self, temporal, expected): def test_max_value(self, temporal, expected): assert temporal.max_value() == expected - # @pytest.mark.parametrize( - # 'temporal, expected', - # [ - # (tti, 'AAA'), - # (ttds, 'AAA'), - # (tts, 'AAA'), - # (ttss, 'AAA') - # ], - # ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] - # ) - # def test_value_at_timestamp(self, temporal, expected): - # assert temporal.value_at_timestamp(datetime(2019, 9, 1)) == expected + @pytest.mark.parametrize( + 'temporal, expected', + [ + (tti, 'AAA'), + (ttds, 'AAA'), + (tts, 'AAA'), + (ttss, 'AAA') + ], + ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] + ) + def test_value_at_timestamp(self, temporal, expected): + assert temporal.value_at_timestamp(datetime(2019, 9, 1)) == expected @pytest.mark.parametrize( 'temporal, expected', @@ -537,27 +550,27 @@ def test_end_instant(self, temporal, expected): 'temporal, expected', [ (tti, tti), - (ttds, TTextInst('BBB@2019-09-02')), - (tts, TTextInst('BBB@2019-09-02')), - (ttss, TTextInst('BBB@2019-09-02')), + (ttds, tti), + (tts, tti), + (ttss, tti), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_max_instant(self, temporal, expected): - assert temporal.max_instant() == expected + def test_min_instant(self, temporal, expected): + assert temporal.min_instant() == expected @pytest.mark.parametrize( 'temporal, expected', [ (tti, tti), - (ttds, tti), - (tts, tti), - (ttss, tti), + (ttds, TTextInst('BBB@2019-09-02')), + (tts, TTextInst('BBB@2019-09-02')), + (ttss, TTextInst('BBB@2019-09-02')), ], ids=['Instant', 'Discrete Sequence', 'Sequence', 'SequenceSet'] ) - def test_min_instant(self, temporal, expected): - assert temporal.min_instant() == expected + def test_max_instant(self, temporal, expected): + assert temporal.max_instant() == expected @pytest.mark.parametrize( 'temporal, n, expected', @@ -671,18 +684,6 @@ def test_timestamps(self, temporal, expected): def test_segments(self, temporal, expected): assert temporal.segments() == expected - @pytest.mark.parametrize( - 'temporal, expected', - [ - (ttds, True), - (tts, True), - ], - ids=['Discrete Sequence', 'Sequence'] - ) - def test_lower_upper_inc(self, temporal, expected): - assert temporal.lower_inc() == expected - assert temporal.upper_inc() == expected - @pytest.mark.parametrize( 'temporal, expected', [ @@ -696,6 +697,33 @@ def test_lower_upper_inc(self, temporal, expected): def test_hash(self, temporal, expected): assert hash(temporal) == expected + def test_value_timestamp(self): + assert self.tti.value() == 'AAA' + assert self.tti.timestamp() == datetime(year=2019, month=9, day=1, tzinfo=timezone.utc) + + @pytest.mark.parametrize( + 'temporal, expected', + [ + (ttds, True), + (tts, True), + ], + ids=['Discrete Sequence', 'Sequence'] + ) + def test_lower_upper_inc(self, temporal, expected): + assert temporal.lower_inc() == expected + assert temporal.upper_inc() == expected + + def test_sequenceset_sequence_functions(self): + ttss1 =TTextSeqSet('{[AAA@2019-09-01, BBB@2019-09-02],' + '[AAA@2019-09-03, AAA@2019-09-05], [CCC@2019-09-06]}') + assert ttss1.num_sequences() == 3 + assert ttss1.start_sequence() == TTextSeq('[AAA@2019-09-01, BBB@2019-09-02]') + assert ttss1.end_sequence() == TTextSeq('[CCC@2019-09-06]') + assert ttss1.sequence_n(1) == TTextSeq('[AAA@2019-09-03, AAA@2019-09-05]') + assert ttss1.sequences() == [TTextSeq('[AAA@2019-09-01, BBB@2019-09-02]'), + TTextSeq('[AAA@2019-09-03, AAA@2019-09-05]'), + TTextSeq('[CCC@2019-09-06]')] + class TestTTextTransformations(TestTText): tti = TTextInst('AAA@2019-09-01') @@ -820,6 +848,29 @@ def test_shift_tscale(self): TTextSeqSet('{[AAA@2019-09-05 00:00:00, BBB@2019-09-05 00:30:00],' '[AAA@2019-09-05 01:00:00, AAA@2019-09-05 02:00:00]}') + @pytest.mark.parametrize( + 'tint, delta, expected', + [(tti, timedelta(days=4), TTextInst('AAA@2019-09-01')), + (tti, timedelta(hours=12), TTextInst('AAA@2019-09-01')), + (ttds, timedelta(days=4), TTextSeq('{AAA@2019-09-01}')), + (ttds, timedelta(hours=12), TTextSeq('{AAA@2019-09-01, BBB@2019-09-02}')), + (tts, timedelta(days=4), TTextSeq('{AAA@2019-09-01}')), + (tts, timedelta(hours=12), TTextSeq('{AAA@2019-09-01, AAA@2019-09-01 12:00:00, BBB@2019-09-02}')), + (ttss, timedelta(days=4), + TTextSeq('{AAA@2019-09-01,AAA@2019-09-05}')), + (ttss, timedelta(hours=12), + TTextSeq('{AAA@2019-09-01, AAA@2019-09-01 12:00:00, BBB@2019-09-02,' + 'AAA@2019-09-03, AAA@2019-09-03 12:00:00, AAA@2019-09-04, ' + 'AAA@2019-09-04 12:00:00, AAA@2019-09-05}')), + ], + ids=['Instant days', 'Instant hours', + 'Discrete Sequence days', 'Discrete Sequence hours', + 'Sequence days', 'Sequence hours', + 'Sequence Set days', 'Sequence Set hours'] + ) + def test_temporal_sample(self, tint, delta, expected): + assert tint.temporal_sample(delta) == expected + class TestTTextModifications(TestTText): tti = TTextInst('AAA@2019-09-01') diff --git a/pymeos_cffi/pymeos_cffi/__init__.py b/pymeos_cffi/pymeos_cffi/__init__.py index c306c439..cfe3428a 100644 --- a/pymeos_cffi/pymeos_cffi/__init__.py +++ b/pymeos_cffi/pymeos_cffi/__init__.py @@ -214,7 +214,6 @@ 'floatspan_set_intspan', 'geoset_round', 'intspan_set_floatspan', - 'numspan_set_floatspan', 'period_tprecision', 'periodset_tprecision', 'period_shift_tscale', @@ -226,7 +225,9 @@ 'adjacent_bigintspan_bigint', 'adjacent_bigintspanset_bigint', 'adjacent_floatspan_float', + 'adjacent_floatspanset_float', 'adjacent_intspan_int', + 'adjacent_intspanset_int', 'adjacent_period_timestamp', 'adjacent_periodset_timestamp', 'adjacent_span_span', @@ -240,23 +241,33 @@ 'contained_float_floatspanset', 'contained_int_intset', 'contained_int_intspan', + 'contained_int_intspanset', 'contained_set_set', 'contained_span_span', 'contained_span_spanset', 'contained_spanset_span', 'contained_spanset_spanset', + 'contained_text_textset', 'contained_timestamp_period', + 'contained_timestamp_periodset', 'contained_timestamp_timestampset', + 'contains_bigintset_bigint', + 'contains_bigintspan_bigint', + 'contains_bigintspanset_bigint', + 'contains_floatset_float', 'contains_floatspan_float', 'contains_floatspanset_float', + 'contains_intset_int', 'contains_intspan_int', - 'contains_set_set', + 'contains_intspanset_int', 'contains_period_timestamp', 'contains_periodset_timestamp', + 'contains_set_set', 'contains_span_span', 'contains_span_spanset', 'contains_spanset_span', 'contains_spanset_spanset', + 'contains_textset_text', 'contains_timestampset_timestamp', 'overlaps_set_set', 'overlaps_span_span', @@ -693,26 +704,26 @@ 'tor_bool_tbool', 'tor_tbool_bool', 'tor_tbool_tbool', - 'add_float_tnumber', - 'add_int_tnumber', - 'add_tnumber_float', - 'add_tnumber_int', + 'add_float_tfloat', + 'add_int_tint', + 'add_tfloat_float', + 'add_tint_int', 'add_tnumber_tnumber', - 'div_float_tnumber', - 'div_int_tnumber', - 'div_tnumber_float', - 'div_tnumber_int', + 'div_float_tfloat', + 'div_int_tint', + 'div_tfloat_float', + 'div_tint_int', 'div_tnumber_tnumber', 'float_degrees', - 'mult_float_tnumber', - 'mult_int_tnumber', - 'mult_tnumber_float', - 'mult_tnumber_int', + 'mult_float_tfloat', + 'mult_int_tint', + 'mult_tfloat_float', + 'mult_tint_int', 'mult_tnumber_tnumber', - 'sub_float_tnumber', - 'sub_int_tnumber', - 'sub_tnumber_float', - 'sub_tnumber_int', + 'sub_float_tfloat', + 'sub_int_tint', + 'sub_tfloat_float', + 'sub_tint_int', 'sub_tnumber_tnumber', 'tfloat_round', 'tfloat_degrees', diff --git a/pymeos_cffi/pymeos_cffi/builder/build_helpers.py b/pymeos_cffi/pymeos_cffi/builder/build_helpers.py index dca6625b..60674ea2 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_helpers.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_helpers.py @@ -346,8 +346,6 @@ extern LWGEOM *lwgeom_from_gserialized(const GSERIALIZED *g); extern GSERIALIZED *gserialized_from_lwgeom(LWGEOM *geom, size_t *size); -extern static inline LWPOINT *lwgeom_as_lwpoint(const LWGEOM *lwgeom); - extern int32_t lwgeom_get_srid(const LWGEOM *geom); extern double lwpoint_get_x(const LWPOINT *point); diff --git a/pymeos_cffi/pymeos_cffi/builder/meos.h b/pymeos_cffi/pymeos_cffi/builder/meos.h index eae87162..7f6658b3 100644 --- a/pymeos_cffi/pymeos_cffi/builder/meos.h +++ b/pymeos_cffi/pymeos_cffi/builder/meos.h @@ -959,7 +959,6 @@ extern SpanSet *floatspanset_round(const SpanSet *ss, int maxdd); extern void floatspan_set_intspan(const Span *s1, Span *s2); extern Set *geoset_round(const Set *s, int maxdd); extern void intspan_set_floatspan(const Span *s1, Span *s2); -extern void numspan_set_floatspan(const Span *s1, Span *s2); extern Span *period_tprecision(const Span *s, const Interval *duration, TimestampTz torigin); extern SpanSet *periodset_tprecision(const SpanSet *ss, const Interval *duration, TimestampTz torigin); extern Span *period_shift_tscale(const Span *p, const Interval *shift, const Interval *duration); @@ -978,7 +977,9 @@ extern Set *timestampset_shift_tscale(const Set *ts, const Interval *shift, cons extern bool adjacent_bigintspan_bigint(const Span *s, int64 i); extern bool adjacent_bigintspanset_bigint(const SpanSet *ss, int64 i); extern bool adjacent_floatspan_float(const Span *s, double d); +extern bool adjacent_floatspanset_float(const SpanSet *ss, double d); extern bool adjacent_intspan_int(const Span *s, int i); +extern bool adjacent_intspanset_int(const SpanSet *ss, int i); extern bool adjacent_period_timestamp(const Span *p, TimestampTz t); extern bool adjacent_periodset_timestamp(const SpanSet *ps, TimestampTz t); extern bool adjacent_span_span(const Span *s1, const Span *s2); @@ -991,26 +992,35 @@ extern bool contained_float_floatset(double d, const Set *s); extern bool contained_float_floatspan(double d, const Span *s); extern bool contained_float_floatspanset(double d, const SpanSet *ss); extern bool contained_int_intset(int i, const Set *s); -extern bool contained_int_intspanset (int i, const SpanSet *ss); extern bool contained_int_intspan(int i, const Span *s); +extern bool contained_int_intspanset(int i, const SpanSet *ss); extern bool contained_set_set(const Set *s1, const Set *s2); extern bool contained_span_span(const Span *s1, const Span *s2); extern bool contained_span_spanset(const Span *s, const SpanSet *ss); extern bool contained_spanset_span(const SpanSet *ss, const Span *s); extern bool contained_spanset_spanset(const SpanSet *ss1, const SpanSet *ss2); +extern bool contained_text_textset(text *txt, const Set *s); extern bool contained_timestamp_period(TimestampTz t, const Span *p); +extern bool contained_timestamp_periodset(TimestampTz t, const SpanSet *ss); extern bool contained_timestamp_timestampset(TimestampTz t, const Set *ts); +extern bool contains_bigintset_bigint(const Set *s, int64 i); +extern bool contains_bigintspan_bigint(const Span *s, int64 i); +extern bool contains_bigintspanset_bigint(const SpanSet *ss, int64 i); +extern bool contains_floatset_float(const Set *s, double d); extern bool contains_floatspan_float(const Span *s, double d); extern bool contains_floatspanset_float(const SpanSet *ss, double d); +extern bool contains_intset_int(const Set *s, int i); extern bool contains_intspan_int(const Span *s, int i); -extern bool contains_set_set(const Set *s1, const Set *s2); +extern bool contains_intspanset_int(const SpanSet *ss, int i); extern bool contains_period_timestamp(const Span *p, TimestampTz t); extern bool contains_periodset_timestamp(const SpanSet *ps, TimestampTz t); +extern bool contains_set_set(const Set *s1, const Set *s2); extern bool contains_span_span(const Span *s1, const Span *s2); extern bool contains_span_spanset(const Span *s, const SpanSet *ss); extern bool contains_spanset_span(const SpanSet *ss, const Span *s); extern bool contains_spanset_spanset(const SpanSet *ss1, const SpanSet *ss2); -extern bool contains_timestampset_timestamp(const Set *ts, TimestampTz t); +extern bool contains_textset_text(const Set *s, text *t); +extern bool contains_timestampset_timestamp(const Set *s, TimestampTz t); extern bool overlaps_set_set(const Set *s1, const Set *s2); extern bool overlaps_span_span(const Span *s1, const Span *s2); extern bool overlaps_spanset_span(const SpanSet *ss, const Span *s); @@ -1322,7 +1332,7 @@ extern bool overafter_stbox_stbox(const STBox *box1, const STBox *box2); -extern TBox *union_tbox_tbox(const TBox *box1, const TBox *box2); +extern TBox *union_tbox_tbox(const TBox *box1, const TBox *box2, bool strict); extern bool inter_tbox_tbox(const TBox *box1, const TBox *box2, TBox *result); extern TBox *intersection_tbox_tbox(const TBox *box1, const TBox *box2); extern STBox *union_stbox_stbox(const STBox *box1, const STBox *box2, bool strict); @@ -1572,26 +1582,26 @@ extern Temporal *tor_tbool_tbool(const Temporal *temp1, const Temporal *temp2); -extern Temporal *add_float_tnumber(double d, const Temporal *tnumber); -extern Temporal *add_int_tnumber(int i, const Temporal *tnumber); -extern Temporal *add_tnumber_float(const Temporal *tnumber, double d); -extern Temporal *add_tnumber_int(const Temporal *tnumber, int i); +extern Temporal *add_float_tfloat(double d, const Temporal *tnumber); +extern Temporal *add_int_tint(int i, const Temporal *tnumber); +extern Temporal *add_tfloat_float(const Temporal *tnumber, double d); +extern Temporal *add_tint_int(const Temporal *tnumber, int i); extern Temporal *add_tnumber_tnumber(const Temporal *tnumber1, const Temporal *tnumber2); -extern Temporal *div_float_tnumber(double d, const Temporal *tnumber); -extern Temporal *div_int_tnumber(int i, const Temporal *tnumber); -extern Temporal *div_tnumber_float(const Temporal *tnumber, double d); -extern Temporal *div_tnumber_int(const Temporal *tnumber, int i); +extern Temporal *div_float_tfloat(double d, const Temporal *tnumber); +extern Temporal *div_int_tint(int i, const Temporal *tnumber); +extern Temporal *div_tfloat_float(const Temporal *tnumber, double d); +extern Temporal *div_tint_int(const Temporal *tnumber, int i); extern Temporal *div_tnumber_tnumber(const Temporal *tnumber1, const Temporal *tnumber2); extern double float_degrees(double value, bool normalize); -extern Temporal *mult_float_tnumber(double d, const Temporal *tnumber); -extern Temporal *mult_int_tnumber(int i, const Temporal *tnumber); -extern Temporal *mult_tnumber_float(const Temporal *tnumber, double d); -extern Temporal *mult_tnumber_int(const Temporal *tnumber, int i); +extern Temporal *mult_float_tfloat(double d, const Temporal *tnumber); +extern Temporal *mult_int_tint(int i, const Temporal *tnumber); +extern Temporal *mult_tfloat_float(const Temporal *tnumber, double d); +extern Temporal *mult_tint_int(const Temporal *tnumber, int i); extern Temporal *mult_tnumber_tnumber(const Temporal *tnumber1, const Temporal *tnumber2); -extern Temporal *sub_float_tnumber(double d, const Temporal *tnumber); -extern Temporal *sub_int_tnumber(int i, const Temporal *tnumber); -extern Temporal *sub_tnumber_float(const Temporal *tnumber, double d); -extern Temporal *sub_tnumber_int(const Temporal *tnumber, int i); +extern Temporal *sub_float_tfloat(double d, const Temporal *tnumber); +extern Temporal *sub_int_tint(int i, const Temporal *tnumber); +extern Temporal *sub_tfloat_float(const Temporal *tnumber, double d); +extern Temporal *sub_tint_int(const Temporal *tnumber, int i); extern Temporal *sub_tnumber_tnumber(const Temporal *tnumber1, const Temporal *tnumber2); extern Temporal *tfloat_round(const Temporal *temp, int maxdd); extern Temporal *tfloat_degrees(const Temporal *temp, bool normalize); diff --git a/pymeos_cffi/pymeos_cffi/functions.py b/pymeos_cffi/pymeos_cffi/functions.py index 6d7c0b9c..fcc8b1bf 100644 --- a/pymeos_cffi/pymeos_cffi/functions.py +++ b/pymeos_cffi/pymeos_cffi/functions.py @@ -1366,12 +1366,6 @@ def intspan_set_floatspan(s1: 'const Span *', s2: 'Span *') -> None: _lib.intspan_set_floatspan(s1_converted, s2_converted) -def numspan_set_floatspan(s1: 'const Span *', s2: 'Span *') -> None: - s1_converted = _ffi.cast('const Span *', s1) - s2_converted = _ffi.cast('Span *', s2) - _lib.numspan_set_floatspan(s1_converted, s2_converted) - - def period_tprecision(s: 'const Span *', duration: 'const Interval *', torigin: int) -> 'Span *': s_converted = _ffi.cast('const Span *', s) duration_converted = _ffi.cast('const Interval *', duration) @@ -1453,12 +1447,24 @@ def adjacent_floatspan_float(s: 'const Span *', d: float) -> 'bool': return result if result != _ffi.NULL else None +def adjacent_floatspanset_float(ss: 'const SpanSet *', d: float) -> 'bool': + ss_converted = _ffi.cast('const SpanSet *', ss) + result = _lib.adjacent_floatspanset_float(ss_converted, d) + return result if result != _ffi.NULL else None + + def adjacent_intspan_int(s: 'const Span *', i: int) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.adjacent_intspan_int(s_converted, i) return result if result != _ffi.NULL else None +def adjacent_intspanset_int(ss: 'const SpanSet *', i: int) -> 'bool': + ss_converted = _ffi.cast('const SpanSet *', ss) + result = _lib.adjacent_intspanset_int(ss_converted, i) + return result if result != _ffi.NULL else None + + def adjacent_period_timestamp(p: 'const Span *', t: int) -> 'bool': p_converted = _ffi.cast('const Span *', p) t_converted = _ffi.cast('TimestampTz', t) @@ -1545,6 +1551,12 @@ def contained_int_intspan(i: int, s: 'const Span *') -> 'bool': return result if result != _ffi.NULL else None +def contained_int_intspanset(i: int, ss: 'const SpanSet *') -> 'bool': + ss_converted = _ffi.cast('const SpanSet *', ss) + result = _lib.contained_int_intspanset(i, ss_converted) + return result if result != _ffi.NULL else None + + def contained_set_set(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) @@ -1580,6 +1592,13 @@ def contained_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> return result if result != _ffi.NULL else None +def contained_text_textset(txt: str, s: 'const Set *') -> 'bool': + txt_converted = cstring2text(txt) + s_converted = _ffi.cast('const Set *', s) + result = _lib.contained_text_textset(txt_converted, s_converted) + return result if result != _ffi.NULL else None + + def contained_timestamp_period(t: int, p: 'const Span *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) p_converted = _ffi.cast('const Span *', p) @@ -1587,6 +1606,13 @@ def contained_timestamp_period(t: int, p: 'const Span *') -> 'bool': return result if result != _ffi.NULL else None +def contained_timestamp_periodset(t: int, ss: 'const SpanSet *') -> 'bool': + t_converted = _ffi.cast('TimestampTz', t) + ss_converted = _ffi.cast('const SpanSet *', ss) + result = _lib.contained_timestamp_periodset(t_converted, ss_converted) + return result if result != _ffi.NULL else None + + def contained_timestamp_timestampset(t: int, ts: 'const Set *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) ts_converted = _ffi.cast('const Set *', ts) @@ -1594,6 +1620,33 @@ def contained_timestamp_timestampset(t: int, ts: 'const Set *') -> 'bool': return result if result != _ffi.NULL else None +def contains_bigintset_bigint(s: 'const Set *', i: int) -> 'bool': + s_converted = _ffi.cast('const Set *', s) + i_converted = _ffi.cast('int64', i) + result = _lib.contains_bigintset_bigint(s_converted, i_converted) + return result if result != _ffi.NULL else None + + +def contains_bigintspan_bigint(s: 'const Span *', i: int) -> 'bool': + s_converted = _ffi.cast('const Span *', s) + i_converted = _ffi.cast('int64', i) + result = _lib.contains_bigintspan_bigint(s_converted, i_converted) + return result if result != _ffi.NULL else None + + +def contains_bigintspanset_bigint(ss: 'const SpanSet *', i: int) -> 'bool': + ss_converted = _ffi.cast('const SpanSet *', ss) + i_converted = _ffi.cast('int64', i) + result = _lib.contains_bigintspanset_bigint(ss_converted, i_converted) + return result if result != _ffi.NULL else None + + +def contains_floatset_float(s: 'const Set *', d: float) -> 'bool': + s_converted = _ffi.cast('const Set *', s) + result = _lib.contains_floatset_float(s_converted, d) + return result if result != _ffi.NULL else None + + def contains_floatspan_float(s: 'const Span *', d: float) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.contains_floatspan_float(s_converted, d) @@ -1606,16 +1659,21 @@ def contains_floatspanset_float(ss: 'const SpanSet *', d: float) -> 'bool': return result if result != _ffi.NULL else None +def contains_intset_int(s: 'const Set *', i: int) -> 'bool': + s_converted = _ffi.cast('const Set *', s) + result = _lib.contains_intset_int(s_converted, i) + return result if result != _ffi.NULL else None + + def contains_intspan_int(s: 'const Span *', i: int) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.contains_intspan_int(s_converted, i) return result if result != _ffi.NULL else None -def contains_set_set(s1: 'const Set *', s2: 'const Set *') -> 'bool': - s1_converted = _ffi.cast('const Set *', s1) - s2_converted = _ffi.cast('const Set *', s2) - result = _lib.contains_set_set(s1_converted, s2_converted) +def contains_intspanset_int(ss: 'const SpanSet *', i: int) -> 'bool': + ss_converted = _ffi.cast('const SpanSet *', ss) + result = _lib.contains_intspanset_int(ss_converted, i) return result if result != _ffi.NULL else None @@ -1633,6 +1691,13 @@ def contains_periodset_timestamp(ps: 'const SpanSet *', t: int) -> 'bool': return result if result != _ffi.NULL else None +def contains_set_set(s1: 'const Set *', s2: 'const Set *') -> 'bool': + s1_converted = _ffi.cast('const Set *', s1) + s2_converted = _ffi.cast('const Set *', s2) + result = _lib.contains_set_set(s1_converted, s2_converted) + return result if result != _ffi.NULL else None + + def contains_span_span(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) @@ -1661,10 +1726,17 @@ def contains_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> return result if result != _ffi.NULL else None -def contains_timestampset_timestamp(ts: 'const Set *', t: int) -> 'bool': - ts_converted = _ffi.cast('const Set *', ts) +def contains_textset_text(s: 'const Set *', t: str) -> 'bool': + s_converted = _ffi.cast('const Set *', s) + t_converted = cstring2text(t) + result = _lib.contains_textset_text(s_converted, t_converted) + return result if result != _ffi.NULL else None + + +def contains_timestampset_timestamp(s: 'const Set *', t: int) -> 'bool': + s_converted = _ffi.cast('const Set *', s) t_converted = _ffi.cast('TimestampTz', t) - result = _lib.contains_timestampset_timestamp(ts_converted, t_converted) + result = _lib.contains_timestampset_timestamp(s_converted, t_converted) return result if result != _ffi.NULL else None @@ -3354,10 +3426,10 @@ def overafter_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool return result if result != _ffi.NULL else None -def union_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'TBox *': +def union_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *', strict: bool) -> 'TBox *': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) - result = _lib.union_tbox_tbox(box1_converted, box2_converted) + result = _lib.union_tbox_tbox(box1_converted, box2_converted, strict) return result if result != _ffi.NULL else None @@ -4668,27 +4740,27 @@ def tor_tbool_tbool(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'Te return result if result != _ffi.NULL else None -def add_float_tnumber(d: float, tnumber: 'const Temporal *') -> 'Temporal *': +def add_float_tfloat(d: float, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.add_float_tnumber(d, tnumber_converted) + result = _lib.add_float_tfloat(d, tnumber_converted) return result if result != _ffi.NULL else None -def add_int_tnumber(i: int, tnumber: 'const Temporal *') -> 'Temporal *': +def add_int_tint(i: int, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.add_int_tnumber(i, tnumber_converted) + result = _lib.add_int_tint(i, tnumber_converted) return result if result != _ffi.NULL else None -def add_tnumber_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': +def add_tfloat_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.add_tnumber_float(tnumber_converted, d) + result = _lib.add_tfloat_float(tnumber_converted, d) return result if result != _ffi.NULL else None -def add_tnumber_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': +def add_tint_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.add_tnumber_int(tnumber_converted, i) + result = _lib.add_tint_int(tnumber_converted, i) return result if result != _ffi.NULL else None @@ -4699,27 +4771,27 @@ def add_tnumber_tnumber(tnumber1: 'const Temporal *', tnumber2: 'const Temporal return result if result != _ffi.NULL else None -def div_float_tnumber(d: float, tnumber: 'const Temporal *') -> 'Temporal *': +def div_float_tfloat(d: float, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.div_float_tnumber(d, tnumber_converted) + result = _lib.div_float_tfloat(d, tnumber_converted) return result if result != _ffi.NULL else None -def div_int_tnumber(i: int, tnumber: 'const Temporal *') -> 'Temporal *': +def div_int_tint(i: int, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.div_int_tnumber(i, tnumber_converted) + result = _lib.div_int_tint(i, tnumber_converted) return result if result != _ffi.NULL else None -def div_tnumber_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': +def div_tfloat_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.div_tnumber_float(tnumber_converted, d) + result = _lib.div_tfloat_float(tnumber_converted, d) return result if result != _ffi.NULL else None -def div_tnumber_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': +def div_tint_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.div_tnumber_int(tnumber_converted, i) + result = _lib.div_tint_int(tnumber_converted, i) return result if result != _ffi.NULL else None @@ -4735,27 +4807,27 @@ def float_degrees(value: float, normalize: bool) -> 'double': return result if result != _ffi.NULL else None -def mult_float_tnumber(d: float, tnumber: 'const Temporal *') -> 'Temporal *': +def mult_float_tfloat(d: float, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.mult_float_tnumber(d, tnumber_converted) + result = _lib.mult_float_tfloat(d, tnumber_converted) return result if result != _ffi.NULL else None -def mult_int_tnumber(i: int, tnumber: 'const Temporal *') -> 'Temporal *': +def mult_int_tint(i: int, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.mult_int_tnumber(i, tnumber_converted) + result = _lib.mult_int_tint(i, tnumber_converted) return result if result != _ffi.NULL else None -def mult_tnumber_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': +def mult_tfloat_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.mult_tnumber_float(tnumber_converted, d) + result = _lib.mult_tfloat_float(tnumber_converted, d) return result if result != _ffi.NULL else None -def mult_tnumber_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': +def mult_tint_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.mult_tnumber_int(tnumber_converted, i) + result = _lib.mult_tint_int(tnumber_converted, i) return result if result != _ffi.NULL else None @@ -4766,27 +4838,27 @@ def mult_tnumber_tnumber(tnumber1: 'const Temporal *', tnumber2: 'const Temporal return result if result != _ffi.NULL else None -def sub_float_tnumber(d: float, tnumber: 'const Temporal *') -> 'Temporal *': +def sub_float_tfloat(d: float, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.sub_float_tnumber(d, tnumber_converted) + result = _lib.sub_float_tfloat(d, tnumber_converted) return result if result != _ffi.NULL else None -def sub_int_tnumber(i: int, tnumber: 'const Temporal *') -> 'Temporal *': +def sub_int_tint(i: int, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.sub_int_tnumber(i, tnumber_converted) + result = _lib.sub_int_tint(i, tnumber_converted) return result if result != _ffi.NULL else None -def sub_tnumber_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': +def sub_tfloat_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.sub_tnumber_float(tnumber_converted, d) + result = _lib.sub_tfloat_float(tnumber_converted, d) return result if result != _ffi.NULL else None -def sub_tnumber_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': +def sub_tint_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) - result = _lib.sub_tnumber_int(tnumber_converted, i) + result = _lib.sub_tint_int(tnumber_converted, i) return result if result != _ffi.NULL else None From 5351a79414e0cba7e4e065dbf3c36395cb0fc817 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Sat, 19 Aug 2023 21:50:13 +0200 Subject: [PATCH 2/6] Rollback from_time method to previous state. Allow expanding a STBox with another STBox again. --- pymeos/pymeos/boxes/stbox.py | 14 +++++++------ pymeos/tests/boxes/stbox_test.py | 36 ++++++++++++++++---------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/pymeos/pymeos/boxes/stbox.py b/pymeos/pymeos/boxes/stbox.py index e8898e77..ad4bbe48 100644 --- a/pymeos/pymeos/boxes/stbox.py +++ b/pymeos/pymeos/boxes/stbox.py @@ -175,14 +175,13 @@ def from_time(time: Time) -> STBox: timestamp_to_stbox, timestampset_to_stbox, period_to_stbox, periodset_to_stbox """ if isinstance(time, datetime): - result = (datetime, datetime) + result = timestamp_to_stbox(datetime_to_timestamptz(time)) elif isinstance(time, TimestampSet): - result = (time.start_timestamp(), time.end_timestamp()) + result = timestampset_to_stbox(time._inner) elif isinstance(time, Period): - result = (time.lower, time.upper, time.lower_inc, time.upper_inc) + result = period_to_stbox(time._inner) elif isinstance(time, PeriodSet): - result = (time.start_period().lower, time.end_period().upper, - time.start_period().lower_inc, time.end_period().upper_inc) + result = periodset_to_stbox(time._inner) else: raise TypeError(f'Operation not supported with type {time.__class__}') return STBox(_inner=result) @@ -541,7 +540,7 @@ def set_srid(self, value: int) -> STBox: return STBox(_inner=stbox_set_srid(self._inner, value)) # ------------------------- Transformations ------------------------------- - def expand(self, other: Union[int, float, timedelta]) -> STBox: + def expand(self, other: Union[int, float, timedelta, STBox]) -> STBox: """ Expands ``self`` with `other`. If `other` is a :class:`int` or a :class:`float`, the result is equal to ``self`` but with the spatial dimensions @@ -561,6 +560,9 @@ def expand(self, other: Union[int, float, timedelta]) -> STBox: result = stbox_expand_space(self._inner, float(other)) elif isinstance(other, timedelta): result = stbox_expand_time(self._inner, timedelta_to_interval(other)) + elif isinstance(other, STBox): + result = stbox_copy(self._inner) + stbox_expand(other._inner, result) else: raise TypeError(f'Operation not supported with type {other.__class__}') return STBox(_inner=result) diff --git a/pymeos/tests/boxes/stbox_test.py b/pymeos/tests/boxes/stbox_test.py index 16d19526..5bd83410 100644 --- a/pymeos/tests/boxes/stbox_test.py +++ b/pymeos/tests/boxes/stbox_test.py @@ -55,24 +55,24 @@ def test_from_geometry_constructor(self, geometry, expected): assert isinstance(stb, STBox) assert str(stb) == expected - # @pytest.mark.parametrize( - # 'time, expected', - # [ - # (datetime(2019, 9, 1), - # 'STBOX T([2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), - # (TimestampSet('{2019-09-01, 2019-09-02}'), - # 'STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), - # (Period('[2019-09-01, 2019-09-02]'), - # 'STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), - # (PeriodSet('{[2019-09-01, 2019-09-02],[2019-09-03, 2019-09-05]}'), - # 'STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), - # ], - # ids=['Timestamp', 'TimestampSet', 'Period', 'PeriodSet'] - # ) - # def test_from_time_constructor(self, time, expected): - # stb = STBox.from_time(time) - # assert isinstance(stb, STBox) - # assert str(stb) == expected + @pytest.mark.parametrize( + 'time, expected', + [ + (datetime(2019, 9, 1), + 'STBOX T([2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])'), + (TimestampSet('{2019-09-01, 2019-09-02}'), + 'STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), + (Period('[2019-09-01, 2019-09-02]'), + 'STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])'), + (PeriodSet('{[2019-09-01, 2019-09-02],[2019-09-03, 2019-09-05]}'), + 'STBOX T([2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])'), + ], + ids=['Timestamp', 'TimestampSet', 'Period', 'PeriodSet'] + ) + def test_from_time_constructor(self, time, expected): + stb = STBox.from_time(time) + assert isinstance(stb, STBox) + assert str(stb) == expected @pytest.mark.parametrize( 'geometry, time, expected', From 1be28cdf80ad815bda444de7dbf61c789ac29ff4 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Tue, 22 Aug 2023 15:03:22 +0200 Subject: [PATCH 3/6] Errors with cffi callback --- pymeos_cffi/pymeos_cffi/__init__.py | 2 +- .../pymeos_cffi/builder/build_header.py | 2 + .../builder/build_pymeos_functions.py | 38 +- pymeos_cffi/pymeos_cffi/builder/meos.h | 5 +- pymeos_cffi/pymeos_cffi/functions.py | 930 +++++++++++++++++- 5 files changed, 969 insertions(+), 8 deletions(-) diff --git a/pymeos_cffi/pymeos_cffi/__init__.py b/pymeos_cffi/pymeos_cffi/__init__.py index cfe3428a..c8ad0706 100644 --- a/pymeos_cffi/pymeos_cffi/__init__.py +++ b/pymeos_cffi/pymeos_cffi/__init__.py @@ -17,6 +17,7 @@ 'as_tinstant', 'as_tsequence', 'as_tsequenceset', + 'meos_initialize', 'lwpoint_make', 'lwgeom_from_gserialized', 'gserialized_from_lwgeom', @@ -27,7 +28,6 @@ 'lwpoint_get_m', 'lwgeom_has_z', 'lwgeom_has_m', - 'meos_initialize', 'meos_finalize', 'bool_in', 'bool_out', diff --git a/pymeos_cffi/pymeos_cffi/builder/build_header.py b/pymeos_cffi/pymeos_cffi/builder/build_header.py index 31c03895..06043ae3 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_header.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_header.py @@ -42,6 +42,8 @@ def main(header_path, so_path=None): if so_path: content = remove_undefined_functions(content, so_path) + content += '\n\nextern "Python" void py_error_handler(int, char*);' + with open('pymeos_cffi/builder/meos.h', 'w') as f: f.write(content) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py index 28e9464f..8367b864 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py @@ -52,6 +52,22 @@ def __init__(self, ctype: str, ptype: str, conversion: Optional[str]) -> None: _ffi = _meos_cffi.ffi _lib = _meos_cffi.lib +_error = None + + +def _check_error() -> None: + global _error + if _error is not None: + error_copy = _error + _error = None + raise Exception(error_copy) + + +@_ffi.def_extern() +def py_error_handler(error_code, error_msg): + global _error + _error = _ffi.string(error_msg).decode('utf-8') + def create_pointer(object: 'Any', type: str) -> 'Any *': return _ffi.new(f'{type} *', object) @@ -137,9 +153,21 @@ def as_tsequenceset(temporal: 'Temporal *') -> 'TSequenceSet *': # ----------------------End of manually-defined functions---------------------- # ----------------------------------------------------------------------------- +def meos_initialize(tz_str: "Optional[str]") -> None: + tz_str_converted = tz_str.encode('utf-8') if tz_str is not None else _ffi.NULL + _lib.meos_initialize(tz_str_converted, _lib.py_error_handler) + + """ +# List of functions defined in functions.py that shouldn't be exported + +hidden_functions = [ + '_check_error', + 'py_error_handler' +] + function_notes = { } @@ -303,6 +331,8 @@ def main(): named = match.groupdict() function = named['function'] inner_return_type = named['returnType'] + if function == 'py_error_handler': + continue return_type = get_return_type(inner_return_type) inner_params = named['params'] params = get_params(function, inner_params) @@ -316,7 +346,10 @@ def main(): init.write('from .functions import *\n\n') init.write('__all__ = [\n') for fn in f_names: - init.write(f" '{fn.group(1)}',\n") + function_name = fn.group(1) + if function_name in hidden_functions: + continue + init.write(f" '{function_name}',\n") init.write(']\n') @@ -501,6 +534,9 @@ def build_function_string(function_name: str, return_type: ReturnType, parameter function_string = f'{base}' \ f' result = _lib.{function_name}({inner_params})' + # Add error handling + function_string += f'\n _check_error()' + # Add whatever manipulation the result needs (maybe empty) if result_manipulation is not None: function_string += f'\n{result_manipulation}' diff --git a/pymeos_cffi/pymeos_cffi/builder/meos.h b/pymeos_cffi/pymeos_cffi/builder/meos.h index 7f6658b3..65cd1ba7 100644 --- a/pymeos_cffi/pymeos_cffi/builder/meos.h +++ b/pymeos_cffi/pymeos_cffi/builder/meos.h @@ -735,7 +735,7 @@ typedef struct * Initialization of the MEOS library *****************************************************************************/ -extern void meos_initialize(const char *tz_str); +extern void meos_initialize(const char *tz_str, void (*handler_p)(int, char*)); extern void meos_finalize(void); /***************************************************************************** @@ -1869,3 +1869,6 @@ bool tpoint_to_geo_meas(const Temporal *tpoint, const Temporal *measure, bool se //#endif + + +extern "Python" void py_error_handler(int, char*); \ No newline at end of file diff --git a/pymeos_cffi/pymeos_cffi/functions.py b/pymeos_cffi/pymeos_cffi/functions.py index fcc8b1bf..b78a3279 100644 --- a/pymeos_cffi/pymeos_cffi/functions.py +++ b/pymeos_cffi/pymeos_cffi/functions.py @@ -12,6 +12,22 @@ _ffi = _meos_cffi.ffi _lib = _meos_cffi.lib +_error = None + + +def _check_error() -> None: + global _error + if _error is not None: + error_copy = _error + _error = None + raise Exception(error_copy) + + +@_ffi.def_extern() +def py_error_handler(error_code, error_msg): + global _error + _error = _ffi.string(error_msg).decode('utf-8') + def create_pointer(object: 'Any', type: str) -> 'Any *': return _ffi.new(f'{type} *', object) @@ -97,17 +113,24 @@ def as_tsequenceset(temporal: 'Temporal *') -> 'TSequenceSet *': # ----------------------End of manually-defined functions---------------------- # ----------------------------------------------------------------------------- +def meos_initialize(tz_str: "Optional[str]") -> None: + tz_str_converted = tz_str.encode('utf-8') if tz_str is not None else _ffi.NULL + _lib.meos_initialize(tz_str_converted, _lib.py_error_handler) + + def lwpoint_make(srid: 'int32_t', hasz: int, hasm: int, p: 'const POINT4D *') -> 'LWPOINT *': srid_converted = _ffi.cast('int32_t', srid) p_converted = _ffi.cast('const POINT4D *', p) result = _lib.lwpoint_make(srid_converted, hasz, hasm, p_converted) + _check_error() return result if result != _ffi.NULL else None def lwgeom_from_gserialized(g: 'const GSERIALIZED *') -> 'LWGEOM *': g_converted = _ffi.cast('const GSERIALIZED *', g) result = _lib.lwgeom_from_gserialized(g_converted) + _check_error() return result if result != _ffi.NULL else None @@ -115,68 +138,74 @@ def gserialized_from_lwgeom(geom: 'LWGEOM *') -> 'GSERIALIZED *': geom_converted = _ffi.cast('LWGEOM *', geom) size_converted = _ffi.NULL result = _lib.gserialized_from_lwgeom(geom_converted, size_converted) + _check_error() return result if result != _ffi.NULL else None def lwgeom_get_srid(geom: 'const LWGEOM *') -> 'int32_t': geom_converted = _ffi.cast('const LWGEOM *', geom) result = _lib.lwgeom_get_srid(geom_converted) + _check_error() return result if result != _ffi.NULL else None def lwpoint_get_x(point: 'const LWPOINT *') -> 'double': point_converted = _ffi.cast('const LWPOINT *', point) result = _lib.lwpoint_get_x(point_converted) + _check_error() return result if result != _ffi.NULL else None def lwpoint_get_y(point: 'const LWPOINT *') -> 'double': point_converted = _ffi.cast('const LWPOINT *', point) result = _lib.lwpoint_get_y(point_converted) + _check_error() return result if result != _ffi.NULL else None def lwpoint_get_z(point: 'const LWPOINT *') -> 'double': point_converted = _ffi.cast('const LWPOINT *', point) result = _lib.lwpoint_get_z(point_converted) + _check_error() return result if result != _ffi.NULL else None def lwpoint_get_m(point: 'const LWPOINT *') -> 'double': point_converted = _ffi.cast('const LWPOINT *', point) result = _lib.lwpoint_get_m(point_converted) + _check_error() return result if result != _ffi.NULL else None def lwgeom_has_z(geom: 'const LWGEOM *') -> 'int': geom_converted = _ffi.cast('const LWGEOM *', geom) result = _lib.lwgeom_has_z(geom_converted) + _check_error() return result if result != _ffi.NULL else None def lwgeom_has_m(geom: 'const LWGEOM *') -> 'int': geom_converted = _ffi.cast('const LWGEOM *', geom) result = _lib.lwgeom_has_m(geom_converted) + _check_error() return result if result != _ffi.NULL else None -def meos_initialize(tz_str: "Optional[str]") -> None: - tz_str_converted = tz_str.encode('utf-8') if tz_str is not None else _ffi.NULL - _lib.meos_initialize(tz_str_converted) - - def meos_finalize() -> None: _lib.meos_finalize() + _check_error() def bool_in(in_str: str) -> 'bool': in_str_converted = in_str.encode('utf-8') result = _lib.bool_in(in_str_converted) + _check_error() return result if result != _ffi.NULL else None def bool_out(b: bool) -> str: result = _lib.bool_out(b) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -190,12 +219,14 @@ def cstring2text(cstring: str) -> 'text *': def pg_date_in(string: str) -> 'DateADT': string_converted = string.encode('utf-8') result = _lib.pg_date_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def pg_date_out(date: 'DateADT') -> str: date_converted = _ffi.cast('DateADT', date) result = _lib.pg_date_out(date_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -204,6 +235,7 @@ def pg_interval_cmp(interval1: 'const Interval *', interval2: 'const Interval *' interval1_converted = _ffi.cast('const Interval *', interval1) interval2_converted = _ffi.cast('const Interval *', interval2) result = _lib.pg_interval_cmp(interval1_converted, interval2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -211,6 +243,7 @@ def pg_interval_in(string: str, typmod: int) -> 'Interval *': string_converted = string.encode('utf-8') typmod_converted = _ffi.cast('int32', typmod) result = _lib.pg_interval_in(string_converted, typmod_converted) + _check_error() return result if result != _ffi.NULL else None @@ -222,18 +255,21 @@ def pg_interval_make(years: int, months: int, weeks: int, days: int, hours: int, hours_converted = _ffi.cast('int32', hours) mins_converted = _ffi.cast('int32', mins) result = _lib.pg_interval_make(years_converted, months_converted, weeks_converted, days_converted, hours_converted, mins_converted, secs) + _check_error() return result if result != _ffi.NULL else None def pg_interval_mul(span: 'const Interval *', factor: float) -> 'Interval *': span_converted = _ffi.cast('const Interval *', span) result = _lib.pg_interval_mul(span_converted, factor) + _check_error() return result if result != _ffi.NULL else None def pg_interval_out(span: 'const Interval *') -> str: span_converted = _ffi.cast('const Interval *', span) result = _lib.pg_interval_out(span_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -242,6 +278,7 @@ def pg_interval_pl(span1: 'const Interval *', span2: 'const Interval *') -> 'Int span1_converted = _ffi.cast('const Interval *', span1) span2_converted = _ffi.cast('const Interval *', span2) result = _lib.pg_interval_pl(span1_converted, span2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -249,12 +286,14 @@ def pg_time_in(string: str, typmod: int) -> 'TimeADT': string_converted = string.encode('utf-8') typmod_converted = _ffi.cast('int32', typmod) result = _lib.pg_time_in(string_converted, typmod_converted) + _check_error() return result if result != _ffi.NULL else None def pg_time_out(time: 'TimeADT') -> str: time_converted = _ffi.cast('TimeADT', time) result = _lib.pg_time_out(time_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -263,6 +302,7 @@ def pg_timestamp_in(string: str, typmod: int) -> 'Timestamp': string_converted = string.encode('utf-8') typmod_converted = _ffi.cast('int32', typmod) result = _lib.pg_timestamp_in(string_converted, typmod_converted) + _check_error() return result if result != _ffi.NULL else None @@ -270,6 +310,7 @@ def pg_timestamp_mi(dt1: int, dt2: int) -> 'Interval *': dt1_converted = _ffi.cast('TimestampTz', dt1) dt2_converted = _ffi.cast('TimestampTz', dt2) result = _lib.pg_timestamp_mi(dt1_converted, dt2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -277,12 +318,14 @@ def pg_timestamp_mi_interval(timestamp: int, span: 'const Interval *') -> 'Times timestamp_converted = _ffi.cast('TimestampTz', timestamp) span_converted = _ffi.cast('const Interval *', span) result = _lib.pg_timestamp_mi_interval(timestamp_converted, span_converted) + _check_error() return result if result != _ffi.NULL else None def pg_timestamp_out(dt: int) -> str: dt_converted = _ffi.cast('Timestamp', dt) result = _lib.pg_timestamp_out(dt_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -291,6 +334,7 @@ def pg_timestamp_pl_interval(timestamp: int, span: 'const Interval *') -> 'Times timestamp_converted = _ffi.cast('TimestampTz', timestamp) span_converted = _ffi.cast('const Interval *', span) result = _lib.pg_timestamp_pl_interval(timestamp_converted, span_converted) + _check_error() return result if result != _ffi.NULL else None @@ -298,12 +342,14 @@ def pg_timestamptz_in(string: str, typmod: int) -> 'TimestampTz': string_converted = string.encode('utf-8') typmod_converted = _ffi.cast('int32', typmod) result = _lib.pg_timestamptz_in(string_converted, typmod_converted) + _check_error() return result if result != _ffi.NULL else None def pg_timestamptz_out(dt: int) -> str: dt_converted = _ffi.cast('TimestampTz', dt) result = _lib.pg_timestamptz_out(dt_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -318,6 +364,7 @@ def pg_timestamp_to_char(dt: int, fmt: str) -> str: dt_converted = _ffi.cast('Timestamp', dt) fmt_converted = cstring2text(fmt) result = _lib.pg_timestamp_to_char(dt_converted, fmt_converted) + _check_error() result = text2cstring(result) return result if result != _ffi.NULL else None @@ -326,6 +373,7 @@ def pg_timestamptz_to_char(dt: int, fmt: str) -> str: dt_converted = _ffi.cast('TimestampTz', dt) fmt_converted = cstring2text(fmt) result = _lib.pg_timestamptz_to_char(dt_converted, fmt_converted) + _check_error() result = text2cstring(result) return result if result != _ffi.NULL else None @@ -334,6 +382,7 @@ def pg_interval_to_char(it: 'Interval *', fmt: str) -> str: it_converted = _ffi.cast('Interval *', it) fmt_converted = cstring2text(fmt) result = _lib.pg_interval_to_char(it_converted, fmt_converted) + _check_error() result = text2cstring(result) return result if result != _ffi.NULL else None @@ -342,6 +391,7 @@ def pg_to_timestamp(date_txt: str, fmt: str) -> 'TimestampTz': date_txt_converted = cstring2text(date_txt) fmt_converted = cstring2text(fmt) result = _lib.pg_to_timestamp(date_txt_converted, fmt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -349,6 +399,7 @@ def pg_to_date(date_txt: str, fmt: str) -> 'DateADT': date_txt_converted = cstring2text(date_txt) fmt_converted = cstring2text(fmt) result = _lib.pg_to_date(date_txt_converted, fmt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -356,12 +407,14 @@ def gserialized_as_ewkb(geom: 'const GSERIALIZED *', type: str) -> 'bytea *': geom_converted = _ffi.cast('const GSERIALIZED *', geom) type_converted = type.encode('utf-8') result = _lib.gserialized_as_ewkb(geom_converted, type_converted) + _check_error() return result if result != _ffi.NULL else None def gserialized_as_ewkt(geom: 'const GSERIALIZED *', precision: int) -> str: geom_converted = _ffi.cast('const GSERIALIZED *', geom) result = _lib.gserialized_as_ewkt(geom_converted, precision) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -370,6 +423,7 @@ def gserialized_as_geojson(geom: 'const GSERIALIZED *', option: int, precision: geom_converted = _ffi.cast('const GSERIALIZED *', geom) srs_converted = srs.encode('utf-8') if srs is not None else _ffi.NULL result = _lib.gserialized_as_geojson(geom_converted, option, precision, srs_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -378,6 +432,7 @@ def gserialized_as_hexewkb(geom: 'const GSERIALIZED *', type: str) -> str: geom_converted = _ffi.cast('const GSERIALIZED *', geom) type_converted = type.encode('utf-8') result = _lib.gserialized_as_hexewkb(geom_converted, type_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -385,6 +440,7 @@ def gserialized_as_hexewkb(geom: 'const GSERIALIZED *', type: str) -> str: def gserialized_as_text(geom: 'const GSERIALIZED *', precision: int) -> str: geom_converted = _ffi.cast('const GSERIALIZED *', geom) result = _lib.gserialized_as_text(geom_converted, precision) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -393,24 +449,28 @@ def gserialized_from_ewkb(bytea_wkb: 'const bytea *', srid: int) -> 'GSERIALIZED bytea_wkb_converted = _ffi.cast('const bytea *', bytea_wkb) srid_converted = _ffi.cast('int32', srid) result = _lib.gserialized_from_ewkb(bytea_wkb_converted, srid_converted) + _check_error() return result if result != _ffi.NULL else None def gserialized_from_geojson(geojson: str) -> 'GSERIALIZED *': geojson_converted = geojson.encode('utf-8') result = _lib.gserialized_from_geojson(geojson_converted) + _check_error() return result if result != _ffi.NULL else None def gserialized_from_hexewkb(wkt: str) -> 'GSERIALIZED *': wkt_converted = wkt.encode('utf-8') result = _lib.gserialized_from_hexewkb(wkt_converted) + _check_error() return result if result != _ffi.NULL else None def gserialized_from_text(wkt: str, srid: int) -> 'GSERIALIZED *': wkt_converted = wkt.encode('utf-8') result = _lib.gserialized_from_text(wkt_converted, srid) + _check_error() return result if result != _ffi.NULL else None @@ -418,12 +478,14 @@ def gserialized_in(input: str, geom_typmod: int) -> 'GSERIALIZED *': input_converted = input.encode('utf-8') geom_typmod_converted = _ffi.cast('int32', geom_typmod) result = _lib.gserialized_in(input_converted, geom_typmod_converted) + _check_error() return result if result != _ffi.NULL else None def gserialized_out(geom: 'const GSERIALIZED *') -> str: geom_converted = _ffi.cast('const GSERIALIZED *', geom) result = _lib.gserialized_out(geom_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -432,18 +494,21 @@ def pgis_gserialized_same(geom1: 'const GSERIALIZED *', geom2: 'const GSERIALIZE geom1_converted = _ffi.cast('const GSERIALIZED *', geom1) geom2_converted = _ffi.cast('const GSERIALIZED *', geom2) result = _lib.pgis_gserialized_same(geom1_converted, geom2_converted) + _check_error() return result if result != _ffi.NULL else None def bigintset_in(string: str) -> 'Set *': string_converted = string.encode('utf-8') result = _lib.bigintset_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def bigintset_out(set: 'const Set *') -> str: set_converted = _ffi.cast('const Set *', set) result = _lib.bigintset_out(set_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -451,12 +516,14 @@ def bigintset_out(set: 'const Set *') -> str: def bigintspan_in(string: str) -> 'Span *': string_converted = string.encode('utf-8') result = _lib.bigintspan_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def bigintspan_out(s: 'const Span *') -> str: s_converted = _ffi.cast('const Span *', s) result = _lib.bigintspan_out(s_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -464,12 +531,14 @@ def bigintspan_out(s: 'const Span *') -> str: def bigintspanset_in(string: str) -> 'SpanSet *': string_converted = string.encode('utf-8') result = _lib.bigintspanset_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def bigintspanset_out(ss: 'const SpanSet *') -> str: ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.bigintspanset_out(ss_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -477,12 +546,14 @@ def bigintspanset_out(ss: 'const SpanSet *') -> str: def floatset_in(string: str) -> 'Set *': string_converted = string.encode('utf-8') result = _lib.floatset_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def floatset_out(set: 'const Set *', maxdd: int) -> str: set_converted = _ffi.cast('const Set *', set) result = _lib.floatset_out(set_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -490,12 +561,14 @@ def floatset_out(set: 'const Set *', maxdd: int) -> str: def floatspan_in(string: str) -> 'Span *': string_converted = string.encode('utf-8') result = _lib.floatspan_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def floatspan_out(s: 'const Span *', maxdd: int) -> str: s_converted = _ffi.cast('const Span *', s) result = _lib.floatspan_out(s_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -503,12 +576,14 @@ def floatspan_out(s: 'const Span *', maxdd: int) -> str: def floatspanset_in(string: str) -> 'SpanSet *': string_converted = string.encode('utf-8') result = _lib.floatspanset_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def floatspanset_out(ss: 'const SpanSet *', maxdd: int) -> str: ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.floatspanset_out(ss_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -516,12 +591,14 @@ def floatspanset_out(ss: 'const SpanSet *', maxdd: int) -> str: def geogset_in(string: str) -> 'Set *': string_converted = string.encode('utf-8') result = _lib.geogset_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def geogset_out(set: 'const Set *', maxdd: int) -> str: set_converted = _ffi.cast('const Set *', set) result = _lib.geogset_out(set_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -529,12 +606,14 @@ def geogset_out(set: 'const Set *', maxdd: int) -> str: def geomset_in(string: str) -> 'Set *': string_converted = string.encode('utf-8') result = _lib.geomset_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def geomset_out(set: 'const Set *', maxdd: int) -> str: set_converted = _ffi.cast('const Set *', set) result = _lib.geomset_out(set_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -542,6 +621,7 @@ def geomset_out(set: 'const Set *', maxdd: int) -> str: def geoset_as_ewkt(set: 'const Set *', maxdd: int) -> str: set_converted = _ffi.cast('const Set *', set) result = _lib.geoset_as_ewkt(set_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -549,6 +629,7 @@ def geoset_as_ewkt(set: 'const Set *', maxdd: int) -> str: def geoset_as_text(set: 'const Set *', maxdd: int) -> str: set_converted = _ffi.cast('const Set *', set) result = _lib.geoset_as_text(set_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -556,12 +637,14 @@ def geoset_as_text(set: 'const Set *', maxdd: int) -> str: def intset_in(string: str) -> 'Set *': string_converted = string.encode('utf-8') result = _lib.intset_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def intset_out(set: 'const Set *') -> str: set_converted = _ffi.cast('const Set *', set) result = _lib.intset_out(set_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -569,12 +652,14 @@ def intset_out(set: 'const Set *') -> str: def intspan_in(string: str) -> 'Span *': string_converted = string.encode('utf-8') result = _lib.intspan_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def intspan_out(s: 'const Span *') -> str: s_converted = _ffi.cast('const Span *', s) result = _lib.intspan_out(s_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -582,12 +667,14 @@ def intspan_out(s: 'const Span *') -> str: def intspanset_in(string: str) -> 'SpanSet *': string_converted = string.encode('utf-8') result = _lib.intspanset_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def intspanset_out(ss: 'const SpanSet *') -> str: ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.intspanset_out(ss_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -595,12 +682,14 @@ def intspanset_out(ss: 'const SpanSet *') -> str: def period_in(string: str) -> 'Span *': string_converted = string.encode('utf-8') result = _lib.period_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def period_out(s: 'const Span *') -> str: s_converted = _ffi.cast('const Span *', s) result = _lib.period_out(s_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -608,12 +697,14 @@ def period_out(s: 'const Span *') -> str: def periodset_in(string: str) -> 'SpanSet *': string_converted = string.encode('utf-8') result = _lib.periodset_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def periodset_out(ss: 'const SpanSet *') -> str: ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.periodset_out(ss_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -623,6 +714,7 @@ def set_as_hexwkb(s: 'const Set *', variant: int) -> "Tuple[str, 'size_t *']": variant_converted = _ffi.cast('uint8_t', variant) size_out = _ffi.new('size_t *') result = _lib.set_as_hexwkb(s_converted, variant_converted, size_out) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None, size_out[0] @@ -632,6 +724,7 @@ def set_as_wkb(s: 'const Set *', variant: int) -> bytes: variant_converted = _ffi.cast('uint8_t', variant) size_out = _ffi.new('size_t *') result = _lib.set_as_wkb(s_converted, variant_converted, size_out) + _check_error() result_converted = bytes(result[i] for i in range(size_out[0])) if result != _ffi.NULL else None return result_converted @@ -639,6 +732,7 @@ def set_as_wkb(s: 'const Set *', variant: int) -> bytes: def set_from_hexwkb(hexwkb: str) -> 'Set *': hexwkb_converted = hexwkb.encode('utf-8') result = _lib.set_from_hexwkb(hexwkb_converted) + _check_error() return result if result != _ffi.NULL else None @@ -651,6 +745,7 @@ def set_from_wkb(wkb: bytes) -> 'Set *': def set_out(s: 'const Set *', maxdd: int) -> str: s_converted = _ffi.cast('const Set *', s) result = _lib.set_out(s_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -660,6 +755,7 @@ def span_as_wkb(s: 'const Span *', variant: int) -> bytes: variant_converted = _ffi.cast('uint8_t', variant) size_out = _ffi.new('size_t *') result = _lib.span_as_wkb(s_converted, variant_converted, size_out) + _check_error() result_converted = bytes(result[i] for i in range(size_out[0])) if result != _ffi.NULL else None return result_converted @@ -669,6 +765,7 @@ def span_as_hexwkb(s: 'const Span *', variant: int) -> "Tuple[str, 'size_t *']": variant_converted = _ffi.cast('uint8_t', variant) size_out = _ffi.new('size_t *') result = _lib.span_as_hexwkb(s_converted, variant_converted, size_out) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None, size_out[0] @@ -676,6 +773,7 @@ def span_as_hexwkb(s: 'const Span *', variant: int) -> "Tuple[str, 'size_t *']": def span_from_hexwkb(hexwkb: str) -> 'Span *': hexwkb_converted = hexwkb.encode('utf-8') result = _lib.span_from_hexwkb(hexwkb_converted) + _check_error() return result if result != _ffi.NULL else None @@ -688,6 +786,7 @@ def span_from_wkb(wkb: bytes) -> 'Span *': def span_out(s: 'const Span *', maxdd: int) -> str: s_converted = _ffi.cast('const Span *', s) result = _lib.span_out(s_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -697,6 +796,7 @@ def spanset_as_wkb(ss: 'const SpanSet *', variant: int) -> bytes: variant_converted = _ffi.cast('uint8_t', variant) size_out = _ffi.new('size_t *') result = _lib.spanset_as_wkb(ss_converted, variant_converted, size_out) + _check_error() result_converted = bytes(result[i] for i in range(size_out[0])) if result != _ffi.NULL else None return result_converted @@ -706,6 +806,7 @@ def spanset_as_hexwkb(ss: 'const SpanSet *', variant: int) -> "Tuple[str, 'size_ variant_converted = _ffi.cast('uint8_t', variant) size_out = _ffi.new('size_t *') result = _lib.spanset_as_hexwkb(ss_converted, variant_converted, size_out) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None, size_out[0] @@ -713,6 +814,7 @@ def spanset_as_hexwkb(ss: 'const SpanSet *', variant: int) -> "Tuple[str, 'size_ def spanset_from_hexwkb(hexwkb: str) -> 'SpanSet *': hexwkb_converted = hexwkb.encode('utf-8') result = _lib.spanset_from_hexwkb(hexwkb_converted) + _check_error() return result if result != _ffi.NULL else None @@ -725,6 +827,7 @@ def spanset_from_wkb(wkb: bytes) -> 'SpanSet *': def spanset_out(ss: 'const SpanSet *', maxdd: int) -> str: ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_out(ss_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -732,12 +835,14 @@ def spanset_out(ss: 'const SpanSet *', maxdd: int) -> str: def textset_in(string: str) -> 'Set *': string_converted = string.encode('utf-8') result = _lib.textset_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def textset_out(set: 'const Set *') -> str: set_converted = _ffi.cast('const Set *', set) result = _lib.textset_out(set_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -745,12 +850,14 @@ def textset_out(set: 'const Set *') -> str: def timestampset_in(string: str) -> 'Set *': string_converted = string.encode('utf-8') result = _lib.timestampset_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def timestampset_out(set: 'const Set *') -> str: set_converted = _ffi.cast('const Set *', set) result = _lib.timestampset_out(set_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -758,6 +865,7 @@ def timestampset_out(set: 'const Set *') -> str: def bigintset_make(values: 'const int64 *', count: int) -> 'Set *': values_converted = _ffi.cast('const int64 *', values) result = _lib.bigintset_make(values_converted, count) + _check_error() return result if result != _ffi.NULL else None @@ -765,40 +873,47 @@ def bigintspan_make(lower: int, upper: int, lower_inc: bool, upper_inc: bool) -> lower_converted = _ffi.cast('int64', lower) upper_converted = _ffi.cast('int64', upper) result = _lib.bigintspan_make(lower_converted, upper_converted, lower_inc, upper_inc) + _check_error() return result if result != _ffi.NULL else None def floatset_make(values: 'const double *', count: int) -> 'Set *': values_converted = _ffi.cast('const double *', values) result = _lib.floatset_make(values_converted, count) + _check_error() return result if result != _ffi.NULL else None def floatspan_make(lower: float, upper: float, lower_inc: bool, upper_inc: bool) -> 'Span *': result = _lib.floatspan_make(lower, upper, lower_inc, upper_inc) + _check_error() return result if result != _ffi.NULL else None def geogset_make(values: 'const GSERIALIZED **', count: int) -> 'Set *': values_converted = [_ffi.cast('const GSERIALIZED *', x) for x in values] result = _lib.geogset_make(values_converted, count) + _check_error() return result if result != _ffi.NULL else None def geomset_make(values: 'const GSERIALIZED **', count: int) -> 'Set *': values_converted = [_ffi.cast('const GSERIALIZED *', x) for x in values] result = _lib.geomset_make(values_converted, count) + _check_error() return result if result != _ffi.NULL else None def intset_make(values: 'const int *', count: int) -> 'Set *': values_converted = _ffi.cast('const int *', values) result = _lib.intset_make(values_converted, count) + _check_error() return result if result != _ffi.NULL else None def intspan_make(lower: int, upper: int, lower_inc: bool, upper_inc: bool) -> 'Span *': result = _lib.intspan_make(lower, upper, lower_inc, upper_inc) + _check_error() return result if result != _ffi.NULL else None @@ -806,142 +921,167 @@ def period_make(lower: int, upper: int, lower_inc: bool, upper_inc: bool) -> 'Sp lower_converted = _ffi.cast('TimestampTz', lower) upper_converted = _ffi.cast('TimestampTz', upper) result = _lib.period_make(lower_converted, upper_converted, lower_inc, upper_inc) + _check_error() return result if result != _ffi.NULL else None def set_copy(s: 'const Set *') -> 'Set *': s_converted = _ffi.cast('const Set *', s) result = _lib.set_copy(s_converted) + _check_error() return result if result != _ffi.NULL else None def span_copy(s: 'const Span *') -> 'Span *': s_converted = _ffi.cast('const Span *', s) result = _lib.span_copy(s_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_copy(ps: 'const SpanSet *') -> 'SpanSet *': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.spanset_copy(ps_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_make(spans: 'List[Span *]', normalize: bool) -> 'SpanSet *': spans_converted = _ffi.new('Span []', spans) result = _lib.spanset_make(spans_converted, len(spans), normalize) + _check_error() return result if result != _ffi.NULL else None def spanset_make_exp(spans: 'Span *', count: int, maxcount: int, normalize: bool, ordered: bool) -> 'SpanSet *': spans_converted = _ffi.cast('Span *', spans) result = _lib.spanset_make_exp(spans_converted, count, maxcount, normalize, ordered) + _check_error() return result if result != _ffi.NULL else None def spanset_make_free(spans: 'Span *', count: int, normalize: bool) -> 'SpanSet *': spans_converted = _ffi.cast('Span *', spans) result = _lib.spanset_make_free(spans_converted, count, normalize) + _check_error() return result if result != _ffi.NULL else None def textset_make(values: 'const text **', count: int) -> 'Set *': values_converted = [_ffi.cast('const text *', x) for x in values] result = _lib.textset_make(values_converted, count) + _check_error() return result if result != _ffi.NULL else None def timestampset_make(values: List[int], count: int) -> 'Set *': values_converted = [_ffi.cast('const TimestampTz', x) for x in values] result = _lib.timestampset_make(values_converted, count) + _check_error() return result if result != _ffi.NULL else None def bigint_to_bigintset(i: int) -> 'Set *': i_converted = _ffi.cast('int64', i) result = _lib.bigint_to_bigintset(i_converted) + _check_error() return result if result != _ffi.NULL else None def bigint_to_bigintspan(i: int) -> 'Span *': result = _lib.bigint_to_bigintspan(i) + _check_error() return result if result != _ffi.NULL else None def bigint_to_bigintspanset(i: int) -> 'SpanSet *': result = _lib.bigint_to_bigintspanset(i) + _check_error() return result if result != _ffi.NULL else None def float_to_floatset(d: float) -> 'Set *': result = _lib.float_to_floatset(d) + _check_error() return result if result != _ffi.NULL else None def float_to_floatspan(d: float) -> 'Span *': result = _lib.float_to_floatspan(d) + _check_error() return result if result != _ffi.NULL else None def float_to_floatspanset(d: float) -> 'SpanSet *': result = _lib.float_to_floatspanset(d) + _check_error() return result if result != _ffi.NULL else None def int_to_intset(i: int) -> 'Set *': result = _lib.int_to_intset(i) + _check_error() return result if result != _ffi.NULL else None def int_to_intspan(i: int) -> 'Span *': result = _lib.int_to_intspan(i) + _check_error() return result if result != _ffi.NULL else None def int_to_intspanset(i: int) -> 'SpanSet *': result = _lib.int_to_intspanset(i) + _check_error() return result if result != _ffi.NULL else None def set_to_spanset(s: 'const Set *') -> 'SpanSet *': s_converted = _ffi.cast('const Set *', s) result = _lib.set_to_spanset(s_converted) + _check_error() return result if result != _ffi.NULL else None def span_to_spanset(s: 'const Span *') -> 'SpanSet *': s_converted = _ffi.cast('const Span *', s) result = _lib.span_to_spanset(s_converted) + _check_error() return result if result != _ffi.NULL else None def timestamp_to_period(t: int) -> 'Span *': t_converted = _ffi.cast('TimestampTz', t) result = _lib.timestamp_to_period(t_converted) + _check_error() return result if result != _ffi.NULL else None def timestamp_to_periodset(t: int) -> 'SpanSet *': t_converted = _ffi.cast('TimestampTz', t) result = _lib.timestamp_to_periodset(t_converted) + _check_error() return result if result != _ffi.NULL else None def timestamp_to_tstzset(t: int) -> 'Set *': t_converted = _ffi.cast('TimestampTz', t) result = _lib.timestamp_to_tstzset(t_converted) + _check_error() return result if result != _ffi.NULL else None def bigintset_end_value(s: 'const Set *') -> 'int64': s_converted = _ffi.cast('const Set *', s) result = _lib.bigintset_end_value(s_converted) + _check_error() return result if result != _ffi.NULL else None def bigintset_start_value(s: 'const Set *') -> 'int64': s_converted = _ffi.cast('const Set *', s) result = _lib.bigintset_start_value(s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -949,6 +1089,7 @@ def bigintset_value_n(s: 'const Set *', n: int) -> 'int64': s_converted = _ffi.cast('const Set *', s) out_result = _ffi.new('int64 *') result = _lib.bigintset_value_n(s_converted, n, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -957,42 +1098,49 @@ def bigintset_value_n(s: 'const Set *', n: int) -> 'int64': def bigintset_values(s: 'const Set *') -> 'int64 *': s_converted = _ffi.cast('const Set *', s) result = _lib.bigintset_values(s_converted) + _check_error() return result if result != _ffi.NULL else None def bigintspan_lower(s: 'const Span *') -> 'int': s_converted = _ffi.cast('const Span *', s) result = _lib.bigintspan_lower(s_converted) + _check_error() return result if result != _ffi.NULL else None def bigintspan_upper(s: 'const Span *') -> 'int': s_converted = _ffi.cast('const Span *', s) result = _lib.bigintspan_upper(s_converted) + _check_error() return result if result != _ffi.NULL else None def bigintspanset_lower(ss: 'const SpanSet *') -> 'int': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.bigintspanset_lower(ss_converted) + _check_error() return result if result != _ffi.NULL else None def bigintspanset_upper(ss: 'const SpanSet *') -> 'int': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.bigintspanset_upper(ss_converted) + _check_error() return result if result != _ffi.NULL else None def floatset_end_value(s: 'const Set *') -> 'double': s_converted = _ffi.cast('const Set *', s) result = _lib.floatset_end_value(s_converted) + _check_error() return result if result != _ffi.NULL else None def floatset_start_value(s: 'const Set *') -> 'double': s_converted = _ffi.cast('const Set *', s) result = _lib.floatset_start_value(s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1000,6 +1148,7 @@ def floatset_value_n(s: 'const Set *', n: int) -> 'double': s_converted = _ffi.cast('const Set *', s) out_result = _ffi.new('double *') result = _lib.floatset_value_n(s_converted, n, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -1008,48 +1157,56 @@ def floatset_value_n(s: 'const Set *', n: int) -> 'double': def floatset_values(s: 'const Set *') -> 'double *': s_converted = _ffi.cast('const Set *', s) result = _lib.floatset_values(s_converted) + _check_error() return result if result != _ffi.NULL else None def floatspan_lower(s: 'const Span *') -> 'double': s_converted = _ffi.cast('const Span *', s) result = _lib.floatspan_lower(s_converted) + _check_error() return result if result != _ffi.NULL else None def floatspan_upper(s: 'const Span *') -> 'double': s_converted = _ffi.cast('const Span *', s) result = _lib.floatspan_upper(s_converted) + _check_error() return result if result != _ffi.NULL else None def floatspanset_lower(ss: 'const SpanSet *') -> 'double': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.floatspanset_lower(ss_converted) + _check_error() return result if result != _ffi.NULL else None def floatspanset_upper(ss: 'const SpanSet *') -> 'double': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.floatspanset_upper(ss_converted) + _check_error() return result if result != _ffi.NULL else None def geoset_srid(set: 'const Set *') -> 'int': set_converted = _ffi.cast('const Set *', set) result = _lib.geoset_srid(set_converted) + _check_error() return result if result != _ffi.NULL else None def intset_end_value(s: 'const Set *') -> 'int': s_converted = _ffi.cast('const Set *', s) result = _lib.intset_end_value(s_converted) + _check_error() return result if result != _ffi.NULL else None def intset_start_value(s: 'const Set *') -> 'int': s_converted = _ffi.cast('const Set *', s) result = _lib.intset_start_value(s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1057,6 +1214,7 @@ def intset_value_n(s: 'const Set *', n: int) -> 'int': s_converted = _ffi.cast('const Set *', s) out_result = _ffi.new('int *') result = _lib.intset_value_n(s_converted, n, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -1065,78 +1223,91 @@ def intset_value_n(s: 'const Set *', n: int) -> 'int': def intset_values(s: 'const Set *') -> 'int *': s_converted = _ffi.cast('const Set *', s) result = _lib.intset_values(s_converted) + _check_error() return result if result != _ffi.NULL else None def intspan_lower(s: 'const Span *') -> 'int': s_converted = _ffi.cast('const Span *', s) result = _lib.intspan_lower(s_converted) + _check_error() return result if result != _ffi.NULL else None def intspan_upper(s: 'const Span *') -> 'int': s_converted = _ffi.cast('const Span *', s) result = _lib.intspan_upper(s_converted) + _check_error() return result if result != _ffi.NULL else None def intspanset_lower(ss: 'const SpanSet *') -> 'int': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.intspanset_lower(ss_converted) + _check_error() return result if result != _ffi.NULL else None def intspanset_upper(ss: 'const SpanSet *') -> 'int': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.intspanset_upper(ss_converted) + _check_error() return result if result != _ffi.NULL else None def period_duration(s: 'const Span *') -> 'Interval *': s_converted = _ffi.cast('const Span *', s) result = _lib.period_duration(s_converted) + _check_error() return result if result != _ffi.NULL else None def period_lower(p: 'const Span *') -> 'TimestampTz': p_converted = _ffi.cast('const Span *', p) result = _lib.period_lower(p_converted) + _check_error() return result if result != _ffi.NULL else None def period_upper(p: 'const Span *') -> 'TimestampTz': p_converted = _ffi.cast('const Span *', p) result = _lib.period_upper(p_converted) + _check_error() return result if result != _ffi.NULL else None def periodset_duration(ps: 'const SpanSet *', boundspan: bool) -> 'Interval *': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.periodset_duration(ps_converted, boundspan) + _check_error() return result if result != _ffi.NULL else None def periodset_end_timestamp(ps: 'const SpanSet *') -> 'TimestampTz': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.periodset_end_timestamp(ps_converted) + _check_error() return result if result != _ffi.NULL else None def periodset_lower(ps: 'const SpanSet *') -> 'TimestampTz': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.periodset_lower(ps_converted) + _check_error() return result if result != _ffi.NULL else None def periodset_num_timestamps(ps: 'const SpanSet *') -> 'int': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.periodset_num_timestamps(ps_converted) + _check_error() return result if result != _ffi.NULL else None def periodset_start_timestamp(ps: 'const SpanSet *') -> 'TimestampTz': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.periodset_start_timestamp(ps_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1144,6 +1315,7 @@ def periodset_timestamp_n(ps: 'const SpanSet *', n: int) -> int: ps_converted = _ffi.cast('const SpanSet *', ps) out_result = _ffi.new('TimestampTz *') result = _lib.periodset_timestamp_n(ps_converted, n, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -1153,18 +1325,21 @@ def periodset_timestamps(ps: 'const SpanSet *') -> "Tuple['TimestampTz *', 'int' ps_converted = _ffi.cast('const SpanSet *', ps) count = _ffi.new('int *') result = _lib.periodset_timestamps(ps_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] def periodset_upper(ps: 'const SpanSet *') -> 'TimestampTz': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.periodset_upper(ps_converted) + _check_error() return result if result != _ffi.NULL else None def set_hash(s: 'const Set *') -> 'uint32': s_converted = _ffi.cast('const Set *', s) result = _lib.set_hash(s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1172,30 +1347,35 @@ def set_hash_extended(s: 'const Set *', seed: int) -> 'uint64': s_converted = _ffi.cast('const Set *', s) seed_converted = _ffi.cast('uint64', seed) result = _lib.set_hash_extended(s_converted, seed_converted) + _check_error() return result if result != _ffi.NULL else None def set_mem_size(s: 'const Set *') -> 'int': s_converted = _ffi.cast('const Set *', s) result = _lib.set_mem_size(s_converted) + _check_error() return result if result != _ffi.NULL else None def set_num_values(s: 'const Set *') -> 'int': s_converted = _ffi.cast('const Set *', s) result = _lib.set_num_values(s_converted) + _check_error() return result if result != _ffi.NULL else None def set_span(s: 'const Set *') -> 'Span *': s_converted = _ffi.cast('const Set *', s) result = _lib.set_span(s_converted) + _check_error() return result if result != _ffi.NULL else None def span_hash(s: 'const Span *') -> 'uint32': s_converted = _ffi.cast('const Span *', s) result = _lib.span_hash(s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1203,36 +1383,42 @@ def span_hash_extended(s: 'const Span *', seed: int) -> 'uint64': s_converted = _ffi.cast('const Span *', s) seed_converted = _ffi.cast('uint64', seed) result = _lib.span_hash_extended(s_converted, seed_converted) + _check_error() return result if result != _ffi.NULL else None def span_lower_inc(s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.span_lower_inc(s_converted) + _check_error() return result if result != _ffi.NULL else None def span_upper_inc(s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.span_upper_inc(s_converted) + _check_error() return result if result != _ffi.NULL else None def span_width(s: 'const Span *') -> 'double': s_converted = _ffi.cast('const Span *', s) result = _lib.span_width(s_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_end_span(ss: 'const SpanSet *') -> 'Span *': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_end_span(ss_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_hash(ps: 'const SpanSet *') -> 'uint32': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.spanset_hash(ps_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1240,78 +1426,91 @@ def spanset_hash_extended(ps: 'const SpanSet *', seed: int) -> 'uint64': ps_converted = _ffi.cast('const SpanSet *', ps) seed_converted = _ffi.cast('uint64', seed) result = _lib.spanset_hash_extended(ps_converted, seed_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_lower_inc(ss: 'const SpanSet *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_lower_inc(ss_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_mem_size(ss: 'const SpanSet *') -> 'int': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_mem_size(ss_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_num_spans(ss: 'const SpanSet *') -> 'int': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_num_spans(ss_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_span(ss: 'const SpanSet *') -> 'Span *': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_span(ss_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_span_n(ss: 'const SpanSet *', i: int) -> 'Span *': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_span_n(ss_converted, i) + _check_error() return result if result != _ffi.NULL else None def spanset_spans(ss: 'const SpanSet *') -> 'const Span **': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_spans(ss_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_start_span(ss: 'const SpanSet *') -> 'Span *': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_start_span(ss_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_upper_inc(ss: 'const SpanSet *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_upper_inc(ss_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_width(ss: 'const SpanSet *') -> 'double': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_width(ss_converted) + _check_error() return result if result != _ffi.NULL else None def spatialset_stbox(s: 'const Set *') -> 'STBox *': s_converted = _ffi.cast('const Set *', s) result = _lib.spatialset_stbox(s_converted) + _check_error() return result if result != _ffi.NULL else None def timestampset_end_timestamp(ts: 'const Set *') -> 'TimestampTz': ts_converted = _ffi.cast('const Set *', ts) result = _lib.timestampset_end_timestamp(ts_converted) + _check_error() return result if result != _ffi.NULL else None def timestampset_start_timestamp(ts: 'const Set *') -> 'TimestampTz': ts_converted = _ffi.cast('const Set *', ts) result = _lib.timestampset_start_timestamp(ts_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1319,6 +1518,7 @@ def timestampset_timestamp_n(ts: 'const Set *', n: int) -> int: ts_converted = _ffi.cast('const Set *', ts) out_result = _ffi.new('TimestampTz *') result = _lib.timestampset_timestamp_n(ts_converted, n, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -1327,24 +1527,28 @@ def timestampset_timestamp_n(ts: 'const Set *', n: int) -> int: def timestampset_values(ts: 'const Set *') -> 'TimestampTz *': ts_converted = _ffi.cast('const Set *', ts) result = _lib.timestampset_values(ts_converted) + _check_error() return result if result != _ffi.NULL else None def floatset_round(s: 'const Set *', maxdd: int) -> 'Set *': s_converted = _ffi.cast('const Set *', s) result = _lib.floatset_round(s_converted, maxdd) + _check_error() return result if result != _ffi.NULL else None def floatspan_round(s: 'const Span *', maxdd: int) -> 'Span *': s_converted = _ffi.cast('const Span *', s) result = _lib.floatspan_round(s_converted, maxdd) + _check_error() return result if result != _ffi.NULL else None def floatspanset_round(ss: 'const SpanSet *', maxdd: int) -> 'SpanSet *': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.floatspanset_round(ss_converted, maxdd) + _check_error() return result if result != _ffi.NULL else None @@ -1352,11 +1556,13 @@ def floatspan_set_intspan(s1: 'const Span *', s2: 'Span *') -> None: s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('Span *', s2) _lib.floatspan_set_intspan(s1_converted, s2_converted) + _check_error() def geoset_round(s: 'const Set *', maxdd: int) -> 'Set *': s_converted = _ffi.cast('const Set *', s) result = _lib.geoset_round(s_converted, maxdd) + _check_error() return result if result != _ffi.NULL else None @@ -1364,6 +1570,7 @@ def intspan_set_floatspan(s1: 'const Span *', s2: 'Span *') -> None: s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('Span *', s2) _lib.intspan_set_floatspan(s1_converted, s2_converted) + _check_error() def period_tprecision(s: 'const Span *', duration: 'const Interval *', torigin: int) -> 'Span *': @@ -1371,6 +1578,7 @@ def period_tprecision(s: 'const Span *', duration: 'const Interval *', torigin: duration_converted = _ffi.cast('const Interval *', duration) torigin_converted = _ffi.cast('TimestampTz', torigin) result = _lib.period_tprecision(s_converted, duration_converted, torigin_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1379,6 +1587,7 @@ def periodset_tprecision(ss: 'const SpanSet *', duration: 'const Interval *', to duration_converted = _ffi.cast('const Interval *', duration) torigin_converted = _ffi.cast('TimestampTz', torigin) result = _lib.periodset_tprecision(ss_converted, duration_converted, torigin_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1387,6 +1596,7 @@ def period_shift_tscale(p: 'const Span *', shift: "Optional['const Interval *']" shift_converted = _ffi.cast('const Interval *', shift) if shift is not None else _ffi.NULL duration_converted = _ffi.cast('const Interval *', duration) if duration is not None else _ffi.NULL result = _lib.period_shift_tscale(p_converted, shift_converted, duration_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1395,6 +1605,7 @@ def periodset_shift_tscale(ps: 'const SpanSet *', shift: "Optional['const Interv shift_converted = _ffi.cast('const Interval *', shift) if shift is not None else _ffi.NULL duration_converted = _ffi.cast('const Interval *', duration) if duration is not None else _ffi.NULL result = _lib.periodset_shift_tscale(ps_converted, shift_converted, duration_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1402,6 +1613,7 @@ def set_shift(s: 'const Set *', shift: 'Datum') -> 'Set *': s_converted = _ffi.cast('const Set *', s) shift_converted = _ffi.cast('Datum', shift) result = _lib.set_shift(s_converted, shift_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1409,6 +1621,7 @@ def span_expand(s1: 'const Span *', s2: 'Span *') -> None: s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('Span *', s2) _lib.span_expand(s1_converted, s2_converted) + _check_error() def timestamp_tprecision(t: int, duration: 'const Interval *', torigin: int) -> 'TimestampTz': @@ -1416,6 +1629,7 @@ def timestamp_tprecision(t: int, duration: 'const Interval *', torigin: int) -> duration_converted = _ffi.cast('const Interval *', duration) torigin_converted = _ffi.cast('TimestampTz', torigin) result = _lib.timestamp_tprecision(t_converted, duration_converted, torigin_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1424,6 +1638,7 @@ def timestampset_shift_tscale(ts: 'const Set *', shift: "Optional['const Interva shift_converted = _ffi.cast('const Interval *', shift) if shift is not None else _ffi.NULL duration_converted = _ffi.cast('const Interval *', duration) if duration is not None else _ffi.NULL result = _lib.timestampset_shift_tscale(ts_converted, shift_converted, duration_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1431,6 +1646,7 @@ def adjacent_bigintspan_bigint(s: 'const Span *', i: int) -> 'bool': s_converted = _ffi.cast('const Span *', s) i_converted = _ffi.cast('int64', i) result = _lib.adjacent_bigintspan_bigint(s_converted, i_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1438,30 +1654,35 @@ def adjacent_bigintspanset_bigint(ss: 'const SpanSet *', i: int) -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) i_converted = _ffi.cast('int64', i) result = _lib.adjacent_bigintspanset_bigint(ss_converted, i_converted) + _check_error() return result if result != _ffi.NULL else None def adjacent_floatspan_float(s: 'const Span *', d: float) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.adjacent_floatspan_float(s_converted, d) + _check_error() return result if result != _ffi.NULL else None def adjacent_floatspanset_float(ss: 'const SpanSet *', d: float) -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.adjacent_floatspanset_float(ss_converted, d) + _check_error() return result if result != _ffi.NULL else None def adjacent_intspan_int(s: 'const Span *', i: int) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.adjacent_intspan_int(s_converted, i) + _check_error() return result if result != _ffi.NULL else None def adjacent_intspanset_int(ss: 'const SpanSet *', i: int) -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.adjacent_intspanset_int(ss_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -1469,6 +1690,7 @@ def adjacent_period_timestamp(p: 'const Span *', t: int) -> 'bool': p_converted = _ffi.cast('const Span *', p) t_converted = _ffi.cast('TimestampTz', t) result = _lib.adjacent_period_timestamp(p_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1476,6 +1698,7 @@ def adjacent_periodset_timestamp(ps: 'const SpanSet *', t: int) -> 'bool': ps_converted = _ffi.cast('const SpanSet *', ps) t_converted = _ffi.cast('TimestampTz', t) result = _lib.adjacent_periodset_timestamp(ps_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1483,6 +1706,7 @@ def adjacent_span_span(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.adjacent_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1490,6 +1714,7 @@ def adjacent_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.adjacent_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1497,6 +1722,7 @@ def adjacent_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.adjacent_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1504,6 +1730,7 @@ def contained_bigint_bigintset(i: int, s: 'const Set *') -> 'bool': i_converted = _ffi.cast('int64', i) s_converted = _ffi.cast('const Set *', s) result = _lib.contained_bigint_bigintset(i_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1511,6 +1738,7 @@ def contained_bigint_bigintspan(i: int, s: 'const Span *') -> 'bool': i_converted = _ffi.cast('int64', i) s_converted = _ffi.cast('const Span *', s) result = _lib.contained_bigint_bigintspan(i_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1518,42 +1746,49 @@ def contained_bigint_bigintspanset(i: int, ss: 'const SpanSet *') -> 'bool': i_converted = _ffi.cast('int64', i) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.contained_bigint_bigintspanset(i_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None def contained_float_floatset(d: float, s: 'const Set *') -> 'bool': s_converted = _ffi.cast('const Set *', s) result = _lib.contained_float_floatset(d, s_converted) + _check_error() return result if result != _ffi.NULL else None def contained_float_floatspan(d: float, s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.contained_float_floatspan(d, s_converted) + _check_error() return result if result != _ffi.NULL else None def contained_float_floatspanset(d: float, ss: 'const SpanSet *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.contained_float_floatspanset(d, ss_converted) + _check_error() return result if result != _ffi.NULL else None def contained_int_intset(i: int, s: 'const Set *') -> 'bool': s_converted = _ffi.cast('const Set *', s) result = _lib.contained_int_intset(i, s_converted) + _check_error() return result if result != _ffi.NULL else None def contained_int_intspan(i: int, s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.contained_int_intspan(i, s_converted) + _check_error() return result if result != _ffi.NULL else None def contained_int_intspanset(i: int, ss: 'const SpanSet *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.contained_int_intspanset(i, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1561,6 +1796,7 @@ def contained_set_set(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.contained_set_set(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1568,6 +1804,7 @@ def contained_span_span(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.contained_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1575,6 +1812,7 @@ def contained_span_spanset(s: 'const Span *', ss: 'const SpanSet *') -> 'bool': s_converted = _ffi.cast('const Span *', s) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.contained_span_spanset(s_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1582,6 +1820,7 @@ def contained_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.contained_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1589,6 +1828,7 @@ def contained_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.contained_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1596,6 +1836,7 @@ def contained_text_textset(txt: str, s: 'const Set *') -> 'bool': txt_converted = cstring2text(txt) s_converted = _ffi.cast('const Set *', s) result = _lib.contained_text_textset(txt_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1603,6 +1844,7 @@ def contained_timestamp_period(t: int, p: 'const Span *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) p_converted = _ffi.cast('const Span *', p) result = _lib.contained_timestamp_period(t_converted, p_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1610,6 +1852,7 @@ def contained_timestamp_periodset(t: int, ss: 'const SpanSet *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.contained_timestamp_periodset(t_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1617,6 +1860,7 @@ def contained_timestamp_timestampset(t: int, ts: 'const Set *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) ts_converted = _ffi.cast('const Set *', ts) result = _lib.contained_timestamp_timestampset(t_converted, ts_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1624,6 +1868,7 @@ def contains_bigintset_bigint(s: 'const Set *', i: int) -> 'bool': s_converted = _ffi.cast('const Set *', s) i_converted = _ffi.cast('int64', i) result = _lib.contains_bigintset_bigint(s_converted, i_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1631,6 +1876,7 @@ def contains_bigintspan_bigint(s: 'const Span *', i: int) -> 'bool': s_converted = _ffi.cast('const Span *', s) i_converted = _ffi.cast('int64', i) result = _lib.contains_bigintspan_bigint(s_converted, i_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1638,42 +1884,49 @@ def contains_bigintspanset_bigint(ss: 'const SpanSet *', i: int) -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) i_converted = _ffi.cast('int64', i) result = _lib.contains_bigintspanset_bigint(ss_converted, i_converted) + _check_error() return result if result != _ffi.NULL else None def contains_floatset_float(s: 'const Set *', d: float) -> 'bool': s_converted = _ffi.cast('const Set *', s) result = _lib.contains_floatset_float(s_converted, d) + _check_error() return result if result != _ffi.NULL else None def contains_floatspan_float(s: 'const Span *', d: float) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.contains_floatspan_float(s_converted, d) + _check_error() return result if result != _ffi.NULL else None def contains_floatspanset_float(ss: 'const SpanSet *', d: float) -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.contains_floatspanset_float(ss_converted, d) + _check_error() return result if result != _ffi.NULL else None def contains_intset_int(s: 'const Set *', i: int) -> 'bool': s_converted = _ffi.cast('const Set *', s) result = _lib.contains_intset_int(s_converted, i) + _check_error() return result if result != _ffi.NULL else None def contains_intspan_int(s: 'const Span *', i: int) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.contains_intspan_int(s_converted, i) + _check_error() return result if result != _ffi.NULL else None def contains_intspanset_int(ss: 'const SpanSet *', i: int) -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.contains_intspanset_int(ss_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -1681,6 +1934,7 @@ def contains_period_timestamp(p: 'const Span *', t: int) -> 'bool': p_converted = _ffi.cast('const Span *', p) t_converted = _ffi.cast('TimestampTz', t) result = _lib.contains_period_timestamp(p_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1688,6 +1942,7 @@ def contains_periodset_timestamp(ps: 'const SpanSet *', t: int) -> 'bool': ps_converted = _ffi.cast('const SpanSet *', ps) t_converted = _ffi.cast('TimestampTz', t) result = _lib.contains_periodset_timestamp(ps_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1695,6 +1950,7 @@ def contains_set_set(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.contains_set_set(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1702,6 +1958,7 @@ def contains_span_span(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.contains_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1709,6 +1966,7 @@ def contains_span_spanset(s: 'const Span *', ss: 'const SpanSet *') -> 'bool': s_converted = _ffi.cast('const Span *', s) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.contains_span_spanset(s_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1716,6 +1974,7 @@ def contains_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.contains_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1723,6 +1982,7 @@ def contains_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.contains_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1730,6 +1990,7 @@ def contains_textset_text(s: 'const Set *', t: str) -> 'bool': s_converted = _ffi.cast('const Set *', s) t_converted = cstring2text(t) result = _lib.contains_textset_text(s_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1737,6 +1998,7 @@ def contains_timestampset_timestamp(s: 'const Set *', t: int) -> 'bool': s_converted = _ffi.cast('const Set *', s) t_converted = _ffi.cast('TimestampTz', t) result = _lib.contains_timestampset_timestamp(s_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1744,6 +2006,7 @@ def overlaps_set_set(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.overlaps_set_set(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1751,6 +2014,7 @@ def overlaps_span_span(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.overlaps_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1758,6 +2022,7 @@ def overlaps_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.overlaps_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1765,6 +2030,7 @@ def overlaps_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.overlaps_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1772,6 +2038,7 @@ def after_timestamp_timestampset(t: int, ts: 'const Set *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) ts_converted = _ffi.cast('const Set *', ts) result = _lib.after_timestamp_timestampset(t_converted, ts_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1779,6 +2046,7 @@ def before_periodset_timestamp(ps: 'const SpanSet *', t: int) -> 'bool': ps_converted = _ffi.cast('const SpanSet *', ps) t_converted = _ffi.cast('TimestampTz', t) result = _lib.before_periodset_timestamp(ps_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1786,30 +2054,35 @@ def before_timestamp_timestampset(t: int, ts: 'const Set *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) ts_converted = _ffi.cast('const Set *', ts) result = _lib.before_timestamp_timestampset(t_converted, ts_converted) + _check_error() return result if result != _ffi.NULL else None def left_float_floatspan(d: float, s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.left_float_floatspan(d, s_converted) + _check_error() return result if result != _ffi.NULL else None def left_floatspan_float(s: 'const Span *', d: float) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.left_floatspan_float(s_converted, d) + _check_error() return result if result != _ffi.NULL else None def left_int_intspan(i: int, s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.left_int_intspan(i, s_converted) + _check_error() return result if result != _ffi.NULL else None def left_intspan_int(s: 'const Span *', i: int) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.left_intspan_int(s_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -1817,6 +2090,7 @@ def left_set_set(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.left_set_set(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1824,6 +2098,7 @@ def left_span_span(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.left_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1831,6 +2106,7 @@ def left_span_spanset(s: 'const Span *', ss: 'const SpanSet *') -> 'bool': s_converted = _ffi.cast('const Span *', s) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.left_span_spanset(s_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1838,6 +2114,7 @@ def left_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.left_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1845,6 +2122,7 @@ def left_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'boo ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.left_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1852,6 +2130,7 @@ def overafter_period_timestamp(p: 'const Span *', t: int) -> 'bool': p_converted = _ffi.cast('const Span *', p) t_converted = _ffi.cast('TimestampTz', t) result = _lib.overafter_period_timestamp(p_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1859,6 +2138,7 @@ def overafter_periodset_timestamp(ps: 'const SpanSet *', t: int) -> 'bool': ps_converted = _ffi.cast('const SpanSet *', ps) t_converted = _ffi.cast('TimestampTz', t) result = _lib.overafter_periodset_timestamp(ps_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1866,6 +2146,7 @@ def overafter_timestamp_period(t: int, p: 'const Span *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) p_converted = _ffi.cast('const Span *', p) result = _lib.overafter_timestamp_period(t_converted, p_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1873,6 +2154,7 @@ def overafter_timestamp_periodset(t: int, ps: 'const SpanSet *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.overafter_timestamp_periodset(t_converted, ps_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1880,6 +2162,7 @@ def overafter_timestamp_timestampset(t: int, ts: 'const Set *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) ts_converted = _ffi.cast('const Set *', ts) result = _lib.overafter_timestamp_timestampset(t_converted, ts_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1887,6 +2170,7 @@ def overbefore_period_timestamp(p: 'const Span *', t: int) -> 'bool': p_converted = _ffi.cast('const Span *', p) t_converted = _ffi.cast('TimestampTz', t) result = _lib.overbefore_period_timestamp(p_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1894,6 +2178,7 @@ def overbefore_periodset_timestamp(ps: 'const SpanSet *', t: int) -> 'bool': ps_converted = _ffi.cast('const SpanSet *', ps) t_converted = _ffi.cast('TimestampTz', t) result = _lib.overbefore_periodset_timestamp(ps_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1901,6 +2186,7 @@ def overbefore_timestamp_period(t: int, p: 'const Span *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) p_converted = _ffi.cast('const Span *', p) result = _lib.overbefore_timestamp_period(t_converted, p_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1908,6 +2194,7 @@ def overbefore_timestamp_periodset(t: int, ps: 'const SpanSet *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.overbefore_timestamp_periodset(t_converted, ps_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1915,30 +2202,35 @@ def overbefore_timestamp_timestampset(t: int, ts: 'const Set *') -> 'bool': t_converted = _ffi.cast('TimestampTz', t) ts_converted = _ffi.cast('const Set *', ts) result = _lib.overbefore_timestamp_timestampset(t_converted, ts_converted) + _check_error() return result if result != _ffi.NULL else None def overleft_float_floatspan(d: float, s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.overleft_float_floatspan(d, s_converted) + _check_error() return result if result != _ffi.NULL else None def overleft_floatspan_float(s: 'const Span *', d: float) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.overleft_floatspan_float(s_converted, d) + _check_error() return result if result != _ffi.NULL else None def overleft_int_intspan(i: int, s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.overleft_int_intspan(i, s_converted) + _check_error() return result if result != _ffi.NULL else None def overleft_intspan_int(s: 'const Span *', i: int) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.overleft_intspan_int(s_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -1946,6 +2238,7 @@ def overleft_set_set(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.overleft_set_set(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1953,6 +2246,7 @@ def overleft_span_span(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.overleft_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1960,6 +2254,7 @@ def overleft_span_spanset(s: 'const Span *', ss: 'const SpanSet *') -> 'bool': s_converted = _ffi.cast('const Span *', s) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.overleft_span_spanset(s_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1967,6 +2262,7 @@ def overleft_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.overleft_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -1974,30 +2270,35 @@ def overleft_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.overleft_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None def overright_float_floatspan(d: float, s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.overright_float_floatspan(d, s_converted) + _check_error() return result if result != _ffi.NULL else None def overright_floatspan_float(s: 'const Span *', d: float) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.overright_floatspan_float(s_converted, d) + _check_error() return result if result != _ffi.NULL else None def overright_int_intspan(i: int, s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.overright_int_intspan(i, s_converted) + _check_error() return result if result != _ffi.NULL else None def overright_intspan_int(s: 'const Span *', i: int) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.overright_intspan_int(s_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -2005,6 +2306,7 @@ def overright_set_set(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.overright_set_set(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2012,6 +2314,7 @@ def overright_span_span(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.overright_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2019,6 +2322,7 @@ def overright_span_spanset(s: 'const Span *', ss: 'const SpanSet *') -> 'bool': s_converted = _ffi.cast('const Span *', s) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.overright_span_spanset(s_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2026,6 +2330,7 @@ def overright_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.overright_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2033,30 +2338,35 @@ def overright_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.overright_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None def right_float_floatspan(d: float, s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.right_float_floatspan(d, s_converted) + _check_error() return result if result != _ffi.NULL else None def right_floatspan_float(s: 'const Span *', d: float) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.right_floatspan_float(s_converted, d) + _check_error() return result if result != _ffi.NULL else None def right_int_intspan(i: int, s: 'const Span *') -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.right_int_intspan(i, s_converted) + _check_error() return result if result != _ffi.NULL else None def right_intspan_int(s: 'const Span *', i: int) -> 'bool': s_converted = _ffi.cast('const Span *', s) result = _lib.right_intspan_int(s_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -2064,6 +2374,7 @@ def right_set_set(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.right_set_set(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2071,6 +2382,7 @@ def right_span_span(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.right_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2078,6 +2390,7 @@ def right_span_spanset(s: 'const Span *', ss: 'const SpanSet *') -> 'bool': s_converted = _ffi.cast('const Span *', s) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.right_span_spanset(s_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2085,6 +2398,7 @@ def right_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'bool': ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.right_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2092,6 +2406,7 @@ def right_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'bo ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.right_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2100,6 +2415,7 @@ def bbox_union_span_span(s1: 'const Span *', s2: 'const Span *') -> 'Span *': s2_converted = _ffi.cast('const Span *', s2) out_result = _ffi.new('Span *') _lib.bbox_union_span_span(s1_converted, s2_converted, out_result) + _check_error() return out_result if out_result!= _ffi.NULL else None @@ -2108,6 +2424,7 @@ def intersection_set_set(s1: 'const Set *', s2: 'const Set *') -> 'Set *': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.intersection_set_set(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2116,6 +2433,7 @@ def intersection_period_timestamp(p: 'const Span *', t: int) -> int: t_converted = _ffi.cast('TimestampTz', t) out_result = _ffi.new('TimestampTz *') result = _lib.intersection_period_timestamp(p_converted, t_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2126,6 +2444,7 @@ def intersection_periodset_timestamp(ps: 'const SpanSet *', t: int) -> int: t_converted = _ffi.cast('TimestampTz', t) out_result = _ffi.new('TimestampTz *') result = _lib.intersection_periodset_timestamp(ps_converted, t_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2135,6 +2454,7 @@ def intersection_span_span(s1: 'const Span *', s2: 'const Span *') -> 'Span *': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.intersection_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2142,6 +2462,7 @@ def intersection_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'Span ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.intersection_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2149,6 +2470,7 @@ def intersection_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.intersection_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2157,6 +2479,7 @@ def intersection_timestampset_timestamp(ts: 'const Set *', t: int) -> int: t_converted = _ffi.cast('const TimestampTz', t) out_result = _ffi.new('TimestampTz *') result = _lib.intersection_timestampset_timestamp(ts_converted, t_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2166,6 +2489,7 @@ def minus_set_set(s1: 'const Set *', s2: 'const Set *') -> 'Set *': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.minus_set_set(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2173,6 +2497,7 @@ def minus_period_timestamp(p: 'const Span *', t: int) -> 'SpanSet *': p_converted = _ffi.cast('const Span *', p) t_converted = _ffi.cast('TimestampTz', t) result = _lib.minus_period_timestamp(p_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2180,6 +2505,7 @@ def minus_periodset_timestamp(ps: 'const SpanSet *', t: int) -> 'SpanSet *': ps_converted = _ffi.cast('const SpanSet *', ps) t_converted = _ffi.cast('TimestampTz', t) result = _lib.minus_periodset_timestamp(ps_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2187,6 +2513,7 @@ def minus_span_span(s1: 'const Span *', s2: 'const Span *') -> 'SpanSet *': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.minus_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2194,6 +2521,7 @@ def minus_span_spanset(s: 'const Span *', ss: 'const SpanSet *') -> 'SpanSet *': s_converted = _ffi.cast('const Span *', s) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.minus_span_spanset(s_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2201,6 +2529,7 @@ def minus_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'SpanSet *': ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.minus_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2208,6 +2537,7 @@ def minus_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'Sp ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.minus_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2216,6 +2546,7 @@ def minus_timestamp_period(t: int, p: 'const Span *') -> int: p_converted = _ffi.cast('const Span *', p) out_result = _ffi.new('TimestampTz *') result = _lib.minus_timestamp_period(t_converted, p_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2226,6 +2557,7 @@ def minus_timestamp_periodset(t: int, ps: 'const SpanSet *') -> int: ps_converted = _ffi.cast('const SpanSet *', ps) out_result = _ffi.new('TimestampTz *') result = _lib.minus_timestamp_periodset(t_converted, ps_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2235,6 +2567,7 @@ def minus_timestampset_timestamp(ts: 'const Set *', t: int) -> 'Set *': ts_converted = _ffi.cast('const Set *', ts) t_converted = _ffi.cast('TimestampTz', t) result = _lib.minus_timestampset_timestamp(ts_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2242,6 +2575,7 @@ def union_set_set(s1: 'const Set *', s2: 'const Set *') -> 'Set *': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.union_set_set(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2249,6 +2583,7 @@ def union_period_timestamp(p: 'const Span *', t: int) -> 'SpanSet *': p_converted = _ffi.cast('const Span *', p) t_converted = _ffi.cast('TimestampTz', t) result = _lib.union_period_timestamp(p_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2256,6 +2591,7 @@ def union_periodset_timestamp(ps: 'SpanSet *', t: int) -> 'SpanSet *': ps_converted = _ffi.cast('SpanSet *', ps) t_converted = _ffi.cast('TimestampTz', t) result = _lib.union_periodset_timestamp(ps_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2263,6 +2599,7 @@ def union_span_span(s1: 'const Span *', s2: 'const Span *') -> 'SpanSet *': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.union_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2270,6 +2607,7 @@ def union_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'SpanSet *': ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.union_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2277,6 +2615,7 @@ def union_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'Sp ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.union_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2284,18 +2623,21 @@ def union_timestampset_timestamp(ts: 'const Set *', t: int) -> 'Set *': ts_converted = _ffi.cast('const Set *', ts) t_converted = _ffi.cast('const TimestampTz', t) result = _lib.union_timestampset_timestamp(ts_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None def distance_floatspan_float(s: 'const Span *', d: float) -> 'double': s_converted = _ffi.cast('const Span *', s) result = _lib.distance_floatspan_float(s_converted, d) + _check_error() return result if result != _ffi.NULL else None def distance_intspan_int(s: 'const Span *', i: int) -> 'double': s_converted = _ffi.cast('const Span *', s) result = _lib.distance_intspan_int(s_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -2303,6 +2645,7 @@ def distance_set_set(s1: 'const Set *', s2: 'const Set *') -> 'double': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.distance_set_set(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2310,6 +2653,7 @@ def distance_period_timestamp(p: 'const Span *', t: int) -> 'double': p_converted = _ffi.cast('const Span *', p) t_converted = _ffi.cast('TimestampTz', t) result = _lib.distance_period_timestamp(p_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2317,6 +2661,7 @@ def distance_periodset_timestamp(ps: 'const SpanSet *', t: int) -> 'double': ps_converted = _ffi.cast('const SpanSet *', ps) t_converted = _ffi.cast('TimestampTz', t) result = _lib.distance_periodset_timestamp(ps_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2324,6 +2669,7 @@ def distance_span_span(s1: 'const Span *', s2: 'const Span *') -> 'double': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.distance_span_span(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2331,6 +2677,7 @@ def distance_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'double': ss_converted = _ffi.cast('const SpanSet *', ss) s_converted = _ffi.cast('const Span *', s) result = _lib.distance_spanset_span(ss_converted, s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2338,6 +2685,7 @@ def distance_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.distance_spanset_spanset(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2345,6 +2693,7 @@ def distance_timestampset_timestamp(ts: 'const Set *', t: int) -> 'double': ts_converted = _ffi.cast('const Set *', ts) t_converted = _ffi.cast('TimestampTz', t) result = _lib.distance_timestampset_timestamp(ts_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2352,6 +2701,7 @@ def bigint_extent_transfn(s: 'Span *', i: int) -> 'Span *': s_converted = _ffi.cast('Span *', s) i_converted = _ffi.cast('int64', i) result = _lib.bigint_extent_transfn(s_converted, i_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2359,30 +2709,35 @@ def bigint_union_transfn(state: 'Set *', i: int) -> 'Set *': state_converted = _ffi.cast('Set *', state) i_converted = _ffi.cast('int64', i) result = _lib.bigint_union_transfn(state_converted, i_converted) + _check_error() return result if result != _ffi.NULL else None def float_extent_transfn(s: 'Span *', d: float) -> 'Span *': s_converted = _ffi.cast('Span *', s) result = _lib.float_extent_transfn(s_converted, d) + _check_error() return result if result != _ffi.NULL else None def float_union_transfn(state: 'Set *', d: float) -> 'Set *': state_converted = _ffi.cast('Set *', state) result = _lib.float_union_transfn(state_converted, d) + _check_error() return result if result != _ffi.NULL else None def int_extent_transfn(s: 'Span *', i: int) -> 'Span *': s_converted = _ffi.cast('Span *', s) result = _lib.int_extent_transfn(s_converted, i) + _check_error() return result if result != _ffi.NULL else None def int_union_transfn(state: 'Set *', i: int) -> 'Set *': state_converted = _ffi.cast('Set *', state) result = _lib.int_union_transfn(state_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -2390,6 +2745,7 @@ def period_tcount_transfn(state: "Optional['SkipList *']", p: 'const Span *') -> state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL p_converted = _ffi.cast('const Span *', p) result = _lib.period_tcount_transfn(state_converted, p_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2397,6 +2753,7 @@ def periodset_tcount_transfn(state: "Optional['SkipList *']", ps: 'const SpanSet state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.periodset_tcount_transfn(state_converted, ps_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2404,12 +2761,14 @@ def set_extent_transfn(span: 'Span *', set: 'const Set *') -> 'Span *': span_converted = _ffi.cast('Span *', span) set_converted = _ffi.cast('const Set *', set) result = _lib.set_extent_transfn(span_converted, set_converted) + _check_error() return result if result != _ffi.NULL else None def set_union_finalfn(state: 'Set *') -> 'Set *': state_converted = _ffi.cast('Set *', state) result = _lib.set_union_finalfn(state_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2417,6 +2776,7 @@ def set_union_transfn(state: 'Set *', set: 'Set *') -> 'Set *': state_converted = _ffi.cast('Set *', state) set_converted = _ffi.cast('Set *', set) result = _lib.set_union_transfn(state_converted, set_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2424,6 +2784,7 @@ def span_extent_transfn(s1: 'Span *', s2: 'const Span *') -> 'Span *': s1_converted = _ffi.cast('Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.span_extent_transfn(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2431,6 +2792,7 @@ def span_union_transfn(state: 'SpanSet *', span: 'const Span *') -> 'SpanSet *': state_converted = _ffi.cast('SpanSet *', state) span_converted = _ffi.cast('const Span *', span) result = _lib.span_union_transfn(state_converted, span_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2438,12 +2800,14 @@ def spanset_extent_transfn(s: 'Span *', ss: 'const SpanSet *') -> 'Span *': s_converted = _ffi.cast('Span *', s) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_extent_transfn(s_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None def spanset_union_finalfn(state: 'SpanSet *') -> 'SpanSet *': state_converted = _ffi.cast('SpanSet *', state) result = _lib.spanset_union_finalfn(state_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2451,6 +2815,7 @@ def spanset_union_transfn(state: 'SpanSet *', ss: 'const SpanSet *') -> 'SpanSet state_converted = _ffi.cast('SpanSet *', state) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.spanset_union_transfn(state_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2458,6 +2823,7 @@ def text_union_transfn(state: 'Set *', txt: str) -> 'Set *': state_converted = _ffi.cast('Set *', state) txt_converted = cstring2text(txt) result = _lib.text_union_transfn(state_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2465,6 +2831,7 @@ def timestamp_extent_transfn(p: "Optional['Span *']", t: int) -> 'Span *': p_converted = _ffi.cast('Span *', p) if p is not None else _ffi.NULL t_converted = _ffi.cast('TimestampTz', t) result = _lib.timestamp_extent_transfn(p_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2472,6 +2839,7 @@ def timestamp_tcount_transfn(state: "Optional['SkipList *']", t: int) -> 'SkipLi state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL t_converted = _ffi.cast('TimestampTz', t) result = _lib.timestamp_tcount_transfn(state_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2479,6 +2847,7 @@ def timestamp_union_transfn(state: 'Set *', t: int) -> 'Set *': state_converted = _ffi.cast('Set *', state) t_converted = _ffi.cast('TimestampTz', t) result = _lib.timestamp_union_transfn(state_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2486,6 +2855,7 @@ def timestampset_tcount_transfn(state: "Optional['SkipList *']", ts: 'const Set state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL ts_converted = _ffi.cast('const Set *', ts) result = _lib.timestampset_tcount_transfn(state_converted, ts_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2493,6 +2863,7 @@ def set_cmp(s1: 'const Set *', s2: 'const Set *') -> 'int': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.set_cmp(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2500,6 +2871,7 @@ def set_eq(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.set_eq(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2507,6 +2879,7 @@ def set_ge(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.set_ge(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2514,6 +2887,7 @@ def set_gt(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.set_gt(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2521,6 +2895,7 @@ def set_le(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.set_le(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2528,6 +2903,7 @@ def set_lt(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.set_lt(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2535,6 +2911,7 @@ def set_ne(s1: 'const Set *', s2: 'const Set *') -> 'bool': s1_converted = _ffi.cast('const Set *', s1) s2_converted = _ffi.cast('const Set *', s2) result = _lib.set_ne(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2542,6 +2919,7 @@ def span_cmp(s1: 'const Span *', s2: 'const Span *') -> 'int': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.span_cmp(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2549,6 +2927,7 @@ def span_eq(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.span_eq(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2556,6 +2935,7 @@ def span_ge(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.span_ge(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2563,6 +2943,7 @@ def span_gt(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.span_gt(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2570,6 +2951,7 @@ def span_le(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.span_le(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2577,6 +2959,7 @@ def span_lt(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.span_lt(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2584,6 +2967,7 @@ def span_ne(s1: 'const Span *', s2: 'const Span *') -> 'bool': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) result = _lib.span_ne(s1_converted, s2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2591,6 +2975,7 @@ def spanset_cmp(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'int': ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.spanset_cmp(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2598,6 +2983,7 @@ def spanset_eq(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'bool': ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.spanset_eq(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2605,6 +2991,7 @@ def spanset_ge(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'bool': ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.spanset_ge(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2612,6 +2999,7 @@ def spanset_gt(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'bool': ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.spanset_gt(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2619,6 +3007,7 @@ def spanset_le(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'bool': ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.spanset_le(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2626,6 +3015,7 @@ def spanset_lt(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'bool': ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.spanset_lt(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2633,18 +3023,21 @@ def spanset_ne(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'bool': ss1_converted = _ffi.cast('const SpanSet *', ss1) ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.spanset_ne(ss1_converted, ss2_converted) + _check_error() return result if result != _ffi.NULL else None def tbox_in(string: str) -> 'TBox *': string_converted = string.encode('utf-8') result = _lib.tbox_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def tbox_out(box: 'const TBox *', maxdd: int) -> str: box_converted = _ffi.cast('const TBox *', box) result = _lib.tbox_out(box_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -2658,6 +3051,7 @@ def tbox_from_wkb(wkb: bytes) -> 'TBOX *': def tbox_from_hexwkb(hexwkb: str) -> 'TBox *': hexwkb_converted = hexwkb.encode('utf-8') result = _lib.tbox_from_hexwkb(hexwkb_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2670,6 +3064,7 @@ def stbox_from_wkb(wkb: bytes) -> 'STBOX *': def stbox_from_hexwkb(hexwkb: str) -> 'STBox *': hexwkb_converted = hexwkb.encode('utf-8') result = _lib.stbox_from_hexwkb(hexwkb_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2678,6 +3073,7 @@ def tbox_as_wkb(box: 'const TBox *', variant: int) -> bytes: variant_converted = _ffi.cast('uint8_t', variant) size_out = _ffi.new('size_t *') result = _lib.tbox_as_wkb(box_converted, variant_converted, size_out) + _check_error() result_converted = bytes(result[i] for i in range(size_out[0])) if result != _ffi.NULL else None return result_converted @@ -2687,6 +3083,7 @@ def tbox_as_hexwkb(box: 'const TBox *', variant: int) -> "Tuple[str, 'size_t *'] variant_converted = _ffi.cast('uint8_t', variant) size = _ffi.new('size_t *') result = _lib.tbox_as_hexwkb(box_converted, variant_converted, size) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None, size[0] @@ -2696,6 +3093,7 @@ def stbox_as_wkb(box: 'const STBox *', variant: int) -> bytes: variant_converted = _ffi.cast('uint8_t', variant) size_out = _ffi.new('size_t *') result = _lib.stbox_as_wkb(box_converted, variant_converted, size_out) + _check_error() result_converted = bytes(result[i] for i in range(size_out[0])) if result != _ffi.NULL else None return result_converted @@ -2705,6 +3103,7 @@ def stbox_as_hexwkb(box: 'const STBox *', variant: int) -> "Tuple[str, 'size_t * variant_converted = _ffi.cast('uint8_t', variant) size = _ffi.new('size_t *') result = _lib.stbox_as_hexwkb(box_converted, variant_converted, size) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None, size[0] @@ -2712,12 +3111,14 @@ def stbox_as_hexwkb(box: 'const STBox *', variant: int) -> "Tuple[str, 'size_t * def stbox_in(string: str) -> 'STBox *': string_converted = string.encode('utf-8') result = _lib.stbox_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def stbox_out(box: 'const STBox *', maxdd: int) -> str: box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_out(box_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -2726,6 +3127,7 @@ def tbox_make(s: "Optional['const Span *']", p: "Optional['const Span *']") -> ' s_converted = _ffi.cast('const Span *', s) if s is not None else _ffi.NULL p_converted = _ffi.cast('const Span *', p) if p is not None else _ffi.NULL result = _lib.tbox_make(s_converted, p_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2734,11 +3136,13 @@ def tbox_set(s: 'const Span *', p: 'const Span *', box: 'TBox *') -> None: p_converted = _ffi.cast('const Span *', p) box_converted = _ffi.cast('TBox *', box) _lib.tbox_set(s_converted, p_converted, box_converted) + _check_error() def tbox_copy(box: 'const TBox *') -> 'TBox *': box_converted = _ffi.cast('const TBox *', box) result = _lib.tbox_copy(box_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2746,6 +3150,7 @@ def stbox_make(hasx: bool, hasz: bool, geodetic: bool, srid: int, xmin: float, x srid_converted = _ffi.cast('int32', srid) p_converted = _ffi.cast('const Span *', p) if p is not None else _ffi.NULL result = _lib.stbox_make(hasx, hasz, geodetic, srid_converted, xmin, xmax, ymin, ymax, zmin, zmax, p_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2754,63 +3159,74 @@ def stbox_set(hasx: bool, hasz: bool, geodetic: bool, srid: int, xmin: float, xm p_converted = _ffi.cast('const Span *', p) box_converted = _ffi.cast('STBox *', box) _lib.stbox_set(hasx, hasz, geodetic, srid_converted, xmin, xmax, ymin, ymax, zmin, zmax, p_converted, box_converted) + _check_error() def stbox_copy(box: 'const STBox *') -> 'STBox *': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_copy(box_converted) + _check_error() return result if result != _ffi.NULL else None def int_to_tbox(i: int) -> 'TBox *': result = _lib.int_to_tbox(i) + _check_error() return result if result != _ffi.NULL else None def float_to_tbox(d: float) -> 'TBox *': result = _lib.float_to_tbox(d) + _check_error() return result if result != _ffi.NULL else None def timestamp_to_tbox(t: int) -> 'TBox *': t_converted = _ffi.cast('TimestampTz', t) result = _lib.timestamp_to_tbox(t_converted) + _check_error() return result if result != _ffi.NULL else None def timestampset_to_tbox(ss: 'const Set *') -> 'TBox *': ss_converted = _ffi.cast('const Set *', ss) result = _lib.timestampset_to_tbox(ss_converted) + _check_error() return result if result != _ffi.NULL else None def period_to_tbox(p: 'const Span *') -> 'TBox *': p_converted = _ffi.cast('const Span *', p) result = _lib.period_to_tbox(p_converted) + _check_error() return result if result != _ffi.NULL else None def periodset_to_tbox(ps: 'const SpanSet *') -> 'TBox *': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.periodset_to_tbox(ps_converted) + _check_error() return result if result != _ffi.NULL else None def int_timestamp_to_tbox(i: int, t: int) -> 'TBox *': t_converted = _ffi.cast('TimestampTz', t) result = _lib.int_timestamp_to_tbox(i, t_converted) + _check_error() return result if result != _ffi.NULL else None def float_period_to_tbox(d: float, p: 'const Span *') -> 'TBox *': p_converted = _ffi.cast('const Span *', p) result = _lib.float_period_to_tbox(d, p_converted) + _check_error() return result if result != _ffi.NULL else None def float_timestamp_to_tbox(d: float, t: int) -> 'TBox *': t_converted = _ffi.cast('TimestampTz', t) result = _lib.float_timestamp_to_tbox(d, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2818,6 +3234,7 @@ def geo_period_to_stbox(gs: 'const GSERIALIZED *', p: 'const Span *') -> 'STBox gs_converted = _ffi.cast('const GSERIALIZED *', gs) p_converted = _ffi.cast('const Span *', p) result = _lib.geo_period_to_stbox(gs_converted, p_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2825,24 +3242,28 @@ def geo_timestamp_to_stbox(gs: 'const GSERIALIZED *', t: int) -> 'STBox *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) t_converted = _ffi.cast('TimestampTz', t) result = _lib.geo_timestamp_to_stbox(gs_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None def geo_to_stbox(gs: 'const GSERIALIZED *') -> 'STBox *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.geo_to_stbox(gs_converted) + _check_error() return result if result != _ffi.NULL else None def int_period_to_tbox(i: int, p: 'const Span *') -> 'TBox *': p_converted = _ffi.cast('const Span *', p) result = _lib.int_period_to_tbox(i, p_converted) + _check_error() return result if result != _ffi.NULL else None def numspan_to_tbox(s: 'const Span *') -> 'TBox *': s_converted = _ffi.cast('const Span *', s) result = _lib.numspan_to_tbox(s_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2850,6 +3271,7 @@ def span_timestamp_to_tbox(span: 'const Span *', t: int) -> 'TBox *': span_converted = _ffi.cast('const Span *', span) t_converted = _ffi.cast('TimestampTz', t) result = _lib.span_timestamp_to_tbox(span_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2857,78 +3279,91 @@ def span_period_to_tbox(span: 'const Span *', p: 'const Span *') -> 'TBox *': span_converted = _ffi.cast('const Span *', span) p_converted = _ffi.cast('const Span *', p) result = _lib.span_period_to_tbox(span_converted, p_converted) + _check_error() return result if result != _ffi.NULL else None def tbox_to_floatspan(box: 'const TBox *') -> 'Span *': box_converted = _ffi.cast('const TBox *', box) result = _lib.tbox_to_floatspan(box_converted) + _check_error() return result if result != _ffi.NULL else None def tbox_to_period(box: 'const TBox *') -> 'Span *': box_converted = _ffi.cast('const TBox *', box) result = _lib.tbox_to_period(box_converted) + _check_error() return result if result != _ffi.NULL else None def stbox_to_period(box: 'const STBox *') -> 'Span *': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_to_period(box_converted) + _check_error() return result if result != _ffi.NULL else None def tnumber_to_tbox(temp: 'const Temporal *') -> 'TBox *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tnumber_to_tbox(temp_converted) + _check_error() return result if result != _ffi.NULL else None def stbox_to_geo(box: 'const STBox *') -> 'GSERIALIZED *': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_to_geo(box_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_to_stbox(temp: 'const Temporal *') -> 'STBox *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_to_stbox(temp_converted) + _check_error() return result if result != _ffi.NULL else None def timestamp_to_stbox(t: int) -> 'STBox *': t_converted = _ffi.cast('TimestampTz', t) result = _lib.timestamp_to_stbox(t_converted) + _check_error() return result if result != _ffi.NULL else None def timestampset_to_stbox(ts: 'const Set *') -> 'STBox *': ts_converted = _ffi.cast('const Set *', ts) result = _lib.timestampset_to_stbox(ts_converted) + _check_error() return result if result != _ffi.NULL else None def period_to_stbox(p: 'const Span *') -> 'STBox *': p_converted = _ffi.cast('const Span *', p) result = _lib.period_to_stbox(p_converted) + _check_error() return result if result != _ffi.NULL else None def periodset_to_stbox(ps: 'const SpanSet *') -> 'STBox *': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.periodset_to_stbox(ps_converted) + _check_error() return result if result != _ffi.NULL else None def tbox_hasx(box: 'const TBox *') -> 'bool': box_converted = _ffi.cast('const TBox *', box) result = _lib.tbox_hasx(box_converted) + _check_error() return result if result != _ffi.NULL else None def tbox_hast(box: 'const TBox *') -> 'bool': box_converted = _ffi.cast('const TBox *', box) result = _lib.tbox_hast(box_converted) + _check_error() return result if result != _ffi.NULL else None @@ -2936,6 +3371,7 @@ def tbox_xmin(box: 'const TBox *') -> 'double': box_converted = _ffi.cast('const TBox *', box) out_result = _ffi.new('double *') result = _lib.tbox_xmin(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2945,6 +3381,7 @@ def tbox_xmin_inc(box: 'const TBox *') -> 'bool': box_converted = _ffi.cast('const TBox *', box) out_result = _ffi.new('bool *') result = _lib.tbox_xmin_inc(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2954,6 +3391,7 @@ def tbox_xmax(box: 'const TBox *') -> 'double': box_converted = _ffi.cast('const TBox *', box) out_result = _ffi.new('double *') result = _lib.tbox_xmax(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2963,6 +3401,7 @@ def tbox_xmax_inc(box: 'const TBox *') -> 'bool': box_converted = _ffi.cast('const TBox *', box) out_result = _ffi.new('bool *') result = _lib.tbox_xmax_inc(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2972,6 +3411,7 @@ def tbox_tmin(box: 'const TBox *') -> int: box_converted = _ffi.cast('const TBox *', box) out_result = _ffi.new('TimestampTz *') result = _lib.tbox_tmin(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2981,6 +3421,7 @@ def tbox_tmin_inc(box: 'const TBox *') -> 'bool': box_converted = _ffi.cast('const TBox *', box) out_result = _ffi.new('bool *') result = _lib.tbox_tmin_inc(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2990,6 +3431,7 @@ def tbox_tmax(box: 'const TBox *') -> int: box_converted = _ffi.cast('const TBox *', box) out_result = _ffi.new('TimestampTz *') result = _lib.tbox_tmax(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -2999,6 +3441,7 @@ def tbox_tmax_inc(box: 'const TBox *') -> 'bool': box_converted = _ffi.cast('const TBox *', box) out_result = _ffi.new('bool *') result = _lib.tbox_tmax_inc(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -3007,24 +3450,28 @@ def tbox_tmax_inc(box: 'const TBox *') -> 'bool': def stbox_hasx(box: 'const STBox *') -> 'bool': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_hasx(box_converted) + _check_error() return result if result != _ffi.NULL else None def stbox_hasz(box: 'const STBox *') -> 'bool': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_hasz(box_converted) + _check_error() return result if result != _ffi.NULL else None def stbox_hast(box: 'const STBox *') -> 'bool': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_hast(box_converted) + _check_error() return result if result != _ffi.NULL else None def stbox_isgeodetic(box: 'const STBox *') -> 'bool': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_isgeodetic(box_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3032,6 +3479,7 @@ def stbox_xmin(box: 'const STBox *') -> 'double': box_converted = _ffi.cast('const STBox *', box) out_result = _ffi.new('double *') result = _lib.stbox_xmin(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -3041,6 +3489,7 @@ def stbox_xmax(box: 'const STBox *') -> 'double': box_converted = _ffi.cast('const STBox *', box) out_result = _ffi.new('double *') result = _lib.stbox_xmax(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -3050,6 +3499,7 @@ def stbox_ymin(box: 'const STBox *') -> 'double': box_converted = _ffi.cast('const STBox *', box) out_result = _ffi.new('double *') result = _lib.stbox_ymin(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -3059,6 +3509,7 @@ def stbox_ymax(box: 'const STBox *') -> 'double': box_converted = _ffi.cast('const STBox *', box) out_result = _ffi.new('double *') result = _lib.stbox_ymax(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -3068,6 +3519,7 @@ def stbox_zmin(box: 'const STBox *') -> 'double': box_converted = _ffi.cast('const STBox *', box) out_result = _ffi.new('double *') result = _lib.stbox_zmin(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -3077,6 +3529,7 @@ def stbox_zmax(box: 'const STBox *') -> 'double': box_converted = _ffi.cast('const STBox *', box) out_result = _ffi.new('double *') result = _lib.stbox_zmax(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -3086,6 +3539,7 @@ def stbox_tmin(box: 'const STBox *') -> int: box_converted = _ffi.cast('const STBox *', box) out_result = _ffi.new('TimestampTz *') result = _lib.stbox_tmin(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -3095,6 +3549,7 @@ def stbox_tmin_inc(box: 'const STBox *') -> 'bool': box_converted = _ffi.cast('const STBox *', box) out_result = _ffi.new('bool *') result = _lib.stbox_tmin_inc(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -3104,6 +3559,7 @@ def stbox_tmax(box: 'const STBox *') -> int: box_converted = _ffi.cast('const STBox *', box) out_result = _ffi.new('TimestampTz *') result = _lib.stbox_tmax(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -3113,6 +3569,7 @@ def stbox_tmax_inc(box: 'const STBox *') -> 'bool': box_converted = _ffi.cast('const STBox *', box) out_result = _ffi.new('bool *') result = _lib.stbox_tmax_inc(box_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -3121,6 +3578,7 @@ def stbox_tmax_inc(box: 'const STBox *') -> 'bool': def stbox_srid(box: 'const STBox *') -> 'int32': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_srid(box_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3128,11 +3586,13 @@ def stbox_expand(box1: 'const STBox *', box2: 'STBox *') -> None: box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('STBox *', box2) _lib.stbox_expand(box1_converted, box2_converted) + _check_error() def stbox_expand_space(box: 'const STBox *', d: float) -> 'STBox *': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_expand_space(box_converted, d) + _check_error() return result if result != _ffi.NULL else None @@ -3140,18 +3600,21 @@ def stbox_expand_time(box: 'const STBox *', interval: 'const Interval *') -> 'ST box_converted = _ffi.cast('const STBox *', box) interval_converted = _ffi.cast('const Interval *', interval) result = _lib.stbox_expand_time(box_converted, interval_converted) + _check_error() return result if result != _ffi.NULL else None def stbox_get_space(box: 'const STBox *') -> 'STBox *': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_get_space(box_converted) + _check_error() return result if result != _ffi.NULL else None def stbox_round(box: 'const STBox *', maxdd: int) -> 'STBox *': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_round(box_converted, maxdd) + _check_error() return result if result != _ffi.NULL else None @@ -3159,6 +3622,7 @@ def stbox_set_srid(box: 'const STBox *', srid: int) -> 'STBox *': box_converted = _ffi.cast('const STBox *', box) srid_converted = _ffi.cast('int32', srid) result = _lib.stbox_set_srid(box_converted, srid_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3166,12 +3630,14 @@ def tbox_expand(box1: 'const TBox *', box2: 'TBox *') -> None: box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('TBox *', box2) _lib.tbox_expand(box1_converted, box2_converted) + _check_error() def tbox_expand_value(box: 'const TBox *', d: 'const double') -> 'TBox *': box_converted = _ffi.cast('const TBox *', box) d_converted = _ffi.cast('const double', d) result = _lib.tbox_expand_value(box_converted, d_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3179,12 +3645,14 @@ def tbox_expand_time(box: 'const TBox *', interval: 'const Interval *') -> 'TBox box_converted = _ffi.cast('const TBox *', box) interval_converted = _ffi.cast('const Interval *', interval) result = _lib.tbox_expand_time(box_converted, interval_converted) + _check_error() return result if result != _ffi.NULL else None def tbox_round(box: 'const TBox *', maxdd: int) -> 'TBox *': box_converted = _ffi.cast('const TBox *', box) result = _lib.tbox_round(box_converted, maxdd) + _check_error() return result if result != _ffi.NULL else None @@ -3192,6 +3660,7 @@ def contains_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.contains_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3199,6 +3668,7 @@ def contained_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.contained_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3206,6 +3676,7 @@ def overlaps_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.overlaps_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3213,6 +3684,7 @@ def same_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.same_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3220,6 +3692,7 @@ def adjacent_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.adjacent_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3227,6 +3700,7 @@ def contains_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool' box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.contains_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3234,6 +3708,7 @@ def contained_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.contained_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3241,6 +3716,7 @@ def overlaps_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool' box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.overlaps_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3248,6 +3724,7 @@ def same_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.same_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3255,6 +3732,7 @@ def adjacent_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool' box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.adjacent_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3262,6 +3740,7 @@ def left_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.left_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3269,6 +3748,7 @@ def overleft_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.overleft_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3276,6 +3756,7 @@ def right_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.right_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3283,6 +3764,7 @@ def overright_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.overright_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3290,6 +3772,7 @@ def before_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.before_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3297,6 +3780,7 @@ def overbefore_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.overbefore_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3304,6 +3788,7 @@ def after_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.after_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3311,6 +3796,7 @@ def overafter_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.overafter_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3318,6 +3804,7 @@ def left_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.left_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3325,6 +3812,7 @@ def overleft_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool' box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.overleft_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3332,6 +3820,7 @@ def right_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.right_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3339,6 +3828,7 @@ def overright_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.overright_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3346,6 +3836,7 @@ def below_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.below_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3353,6 +3844,7 @@ def overbelow_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.overbelow_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3360,6 +3852,7 @@ def above_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.above_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3367,6 +3860,7 @@ def overabove_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.overabove_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3374,6 +3868,7 @@ def front_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.front_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3381,6 +3876,7 @@ def overfront_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.overfront_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3388,6 +3884,7 @@ def back_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.back_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3395,6 +3892,7 @@ def overback_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool' box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.overback_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3402,6 +3900,7 @@ def before_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.before_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3409,6 +3908,7 @@ def overbefore_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'boo box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.overbefore_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3416,6 +3916,7 @@ def after_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.after_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3423,6 +3924,7 @@ def overafter_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'bool box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.overafter_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3430,6 +3932,7 @@ def union_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *', strict: bool) -> box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.union_tbox_tbox(box1_converted, box2_converted, strict) + _check_error() return result if result != _ffi.NULL else None @@ -3438,6 +3941,7 @@ def inter_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'TBox *': box2_converted = _ffi.cast('const TBox *', box2) out_result = _ffi.new('TBox *') result = _lib.inter_tbox_tbox(box1_converted, box2_converted, out_result) + _check_error() if result: return out_result if out_result != _ffi.NULL else None return None @@ -3447,6 +3951,7 @@ def intersection_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'TBox box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.intersection_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3454,6 +3959,7 @@ def union_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *', strict: bool box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.union_stbox_stbox(box1_converted, box2_converted, strict) + _check_error() return result if result != _ffi.NULL else None @@ -3462,6 +3968,7 @@ def inter_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'STBox *' box2_converted = _ffi.cast('const STBox *', box2) out_result = _ffi.new('STBox *') result = _lib.inter_stbox_stbox(box1_converted, box2_converted, out_result) + _check_error() if result: return out_result if out_result != _ffi.NULL else None return None @@ -3471,6 +3978,7 @@ def intersection_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'S box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.intersection_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3478,6 +3986,7 @@ def stbox_quad_split(box: 'const STBox *') -> "Tuple['STBox *', 'int']": box_converted = _ffi.cast('const STBox *', box) count = _ffi.new('int *') result = _lib.stbox_quad_split(box_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] @@ -3485,6 +3994,7 @@ def tbox_eq(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.tbox_eq(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3492,6 +4002,7 @@ def tbox_ne(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.tbox_ne(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3499,6 +4010,7 @@ def tbox_cmp(box1: 'const TBox *', box2: 'const TBox *') -> 'int': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.tbox_cmp(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3506,6 +4018,7 @@ def tbox_lt(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.tbox_lt(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3513,6 +4026,7 @@ def tbox_le(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.tbox_le(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3520,6 +4034,7 @@ def tbox_ge(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.tbox_ge(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3527,6 +4042,7 @@ def tbox_gt(box1: 'const TBox *', box2: 'const TBox *') -> 'bool': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.tbox_gt(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3534,6 +4050,7 @@ def stbox_eq(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.stbox_eq(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3541,6 +4058,7 @@ def stbox_ne(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.stbox_ne(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3548,6 +4066,7 @@ def stbox_cmp(box1: 'const STBox *', box2: 'const STBox *') -> 'int': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.stbox_cmp(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3555,6 +4074,7 @@ def stbox_lt(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.stbox_lt(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3562,6 +4082,7 @@ def stbox_le(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.stbox_le(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3569,6 +4090,7 @@ def stbox_ge(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.stbox_ge(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3576,18 +4098,21 @@ def stbox_gt(box1: 'const STBox *', box2: 'const STBox *') -> 'bool': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.stbox_gt(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None def tbool_in(string: str) -> 'Temporal *': string_converted = string.encode('utf-8') result = _lib.tbool_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def tbool_out(temp: 'const Temporal *') -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tbool_out(temp_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -3597,6 +4122,7 @@ def temporal_as_hexwkb(temp: 'const Temporal *', variant: int) -> "Tuple[str, 's variant_converted = _ffi.cast('uint8_t', variant) size_out = _ffi.new('size_t *') result = _lib.temporal_as_hexwkb(temp_converted, variant_converted, size_out) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None, size_out[0] @@ -3605,6 +4131,7 @@ def temporal_as_mfjson(temp: 'const Temporal *', with_bbox: bool, flags: int, pr temp_converted = _ffi.cast('const Temporal *', temp) srs_converted = srs.encode('utf-8') if srs is not None else _ffi.NULL result = _lib.temporal_as_mfjson(temp_converted, with_bbox, flags, precision, srs_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -3614,6 +4141,7 @@ def temporal_as_wkb(temp: 'const Temporal *', variant: int) -> bytes: variant_converted = _ffi.cast('uint8_t', variant) size_out = _ffi.new('size_t *') result = _lib.temporal_as_wkb(temp_converted, variant_converted, size_out) + _check_error() result_converted = bytes(result[i] for i in range(size_out[0])) if result != _ffi.NULL else None return result_converted @@ -3621,12 +4149,14 @@ def temporal_as_wkb(temp: 'const Temporal *', variant: int) -> bytes: def temporal_from_hexwkb(hexwkb: str) -> 'Temporal *': hexwkb_converted = hexwkb.encode('utf-8') result = _lib.temporal_from_hexwkb(hexwkb_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_from_mfjson(mfjson: str) -> 'Temporal *': mfjson_converted = mfjson.encode('utf-8') result = _lib.temporal_from_mfjson(mfjson_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3639,12 +4169,14 @@ def temporal_from_wkb(wkb: bytes) -> 'Temporal *': def tfloat_in(string: str) -> 'Temporal *': string_converted = string.encode('utf-8') result = _lib.tfloat_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def tfloat_out(temp: 'const Temporal *', maxdd: int) -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_out(temp_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -3652,24 +4184,28 @@ def tfloat_out(temp: 'const Temporal *', maxdd: int) -> str: def tgeogpoint_in(string: str) -> 'Temporal *': string_converted = string.encode('utf-8') result = _lib.tgeogpoint_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def tgeompoint_in(string: str) -> 'Temporal *': string_converted = string.encode('utf-8') result = _lib.tgeompoint_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def tint_in(string: str) -> 'Temporal *': string_converted = string.encode('utf-8') result = _lib.tint_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def tint_out(temp: 'const Temporal *') -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_out(temp_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -3677,6 +4213,7 @@ def tint_out(temp: 'const Temporal *') -> str: def tpoint_as_ewkt(temp: 'const Temporal *', maxdd: int) -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_as_ewkt(temp_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -3684,6 +4221,7 @@ def tpoint_as_ewkt(temp: 'const Temporal *', maxdd: int) -> str: def tpoint_as_text(temp: 'const Temporal *', maxdd: int) -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_as_text(temp_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -3691,6 +4229,7 @@ def tpoint_as_text(temp: 'const Temporal *', maxdd: int) -> str: def tpoint_out(temp: 'const Temporal *', maxdd: int) -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_out(temp_converted, maxdd) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -3698,12 +4237,14 @@ def tpoint_out(temp: 'const Temporal *', maxdd: int) -> str: def ttext_in(string: str) -> 'Temporal *': string_converted = string.encode('utf-8') result = _lib.ttext_in(string_converted) + _check_error() return result if result != _ffi.NULL else None def ttext_out(temp: 'const Temporal *') -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.ttext_out(temp_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -3711,48 +4252,56 @@ def ttext_out(temp: 'const Temporal *') -> str: def tbool_from_base_temp(b: bool, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tbool_from_base_temp(b, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tboolinst_make(b: bool, t: int) -> 'TInstant *': t_converted = _ffi.cast('TimestampTz', t) result = _lib.tboolinst_make(b, t_converted) + _check_error() return result if result != _ffi.NULL else None def tboolseq_from_base_period(b: bool, p: 'const Span *') -> 'TSequence *': p_converted = _ffi.cast('const Span *', p) result = _lib.tboolseq_from_base_period(b, p_converted) + _check_error() return result if result != _ffi.NULL else None def tboolseq_from_base_timestampset(b: bool, ts: 'const Set *') -> 'TSequence *': ts_converted = _ffi.cast('const Set *', ts) result = _lib.tboolseq_from_base_timestampset(b, ts_converted) + _check_error() return result if result != _ffi.NULL else None def tboolseqset_from_base_periodset(b: bool, ps: 'const SpanSet *') -> 'TSequenceSet *': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.tboolseqset_from_base_periodset(b, ps_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_copy(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_copy(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tfloat_from_base_temp(d: float, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_from_base_temp(d, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tfloatinst_make(d: float, t: int) -> 'TInstant *': t_converted = _ffi.cast('TimestampTz', t) result = _lib.tfloatinst_make(d, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3760,12 +4309,14 @@ def tfloatseq_from_base_period(d: float, p: 'const Span *', interp: 'interpType' p_converted = _ffi.cast('const Span *', p) interp_converted = _ffi.cast('interpType', interp) result = _lib.tfloatseq_from_base_period(d, p_converted, interp_converted) + _check_error() return result if result != _ffi.NULL else None def tfloatseq_from_base_timestampset(d: float, ts: 'const Set *') -> 'TSequence *': ts_converted = _ffi.cast('const Set *', ts) result = _lib.tfloatseq_from_base_timestampset(d, ts_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3773,6 +4324,7 @@ def tfloatseqset_from_base_periodset(d: float, ps: 'const SpanSet *', interp: 'i ps_converted = _ffi.cast('const SpanSet *', ps) interp_converted = _ffi.cast('interpType', interp) result = _lib.tfloatseqset_from_base_periodset(d, ps_converted, interp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3780,6 +4332,7 @@ def tgeogpoint_from_base_temp(gs: 'const GSERIALIZED *', temp: 'const Temporal * gs_converted = _ffi.cast('const GSERIALIZED *', gs) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tgeogpoint_from_base_temp(gs_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3787,6 +4340,7 @@ def tgeogpointinst_make(gs: 'const GSERIALIZED *', t: int) -> 'TInstant *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) t_converted = _ffi.cast('TimestampTz', t) result = _lib.tgeogpointinst_make(gs_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3795,6 +4349,7 @@ def tgeogpointseq_from_base_period(gs: 'const GSERIALIZED *', p: 'const Span *', p_converted = _ffi.cast('const Span *', p) interp_converted = _ffi.cast('interpType', interp) result = _lib.tgeogpointseq_from_base_period(gs_converted, p_converted, interp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3802,6 +4357,7 @@ def tgeogpointseq_from_base_timestampset(gs: 'const GSERIALIZED *', ts: 'const S gs_converted = _ffi.cast('const GSERIALIZED *', gs) ts_converted = _ffi.cast('const Set *', ts) result = _lib.tgeogpointseq_from_base_timestampset(gs_converted, ts_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3810,6 +4366,7 @@ def tgeogpointseqset_from_base_periodset(gs: 'const GSERIALIZED *', ps: 'const S ps_converted = _ffi.cast('const SpanSet *', ps) interp_converted = _ffi.cast('interpType', interp) result = _lib.tgeogpointseqset_from_base_periodset(gs_converted, ps_converted, interp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3817,6 +4374,7 @@ def tgeompoint_from_base_temp(gs: 'const GSERIALIZED *', temp: 'const Temporal * gs_converted = _ffi.cast('const GSERIALIZED *', gs) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tgeompoint_from_base_temp(gs_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3824,6 +4382,7 @@ def tgeompointinst_make(gs: 'const GSERIALIZED *', t: int) -> 'TInstant *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) t_converted = _ffi.cast('TimestampTz', t) result = _lib.tgeompointinst_make(gs_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3832,6 +4391,7 @@ def tgeompointseq_from_base_period(gs: 'const GSERIALIZED *', p: 'const Span *', p_converted = _ffi.cast('const Span *', p) interp_converted = _ffi.cast('interpType', interp) result = _lib.tgeompointseq_from_base_period(gs_converted, p_converted, interp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3839,6 +4399,7 @@ def tgeompointseq_from_base_timestampset(gs: 'const GSERIALIZED *', ts: 'const S gs_converted = _ffi.cast('const GSERIALIZED *', gs) ts_converted = _ffi.cast('const Set *', ts) result = _lib.tgeompointseq_from_base_timestampset(gs_converted, ts_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3847,36 +4408,42 @@ def tgeompointseqset_from_base_periodset(gs: 'const GSERIALIZED *', ps: 'const S ps_converted = _ffi.cast('const SpanSet *', ps) interp_converted = _ffi.cast('interpType', interp) result = _lib.tgeompointseqset_from_base_periodset(gs_converted, ps_converted, interp_converted) + _check_error() return result if result != _ffi.NULL else None def tint_from_base_temp(i: int, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_from_base_temp(i, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tintinst_make(i: int, t: int) -> 'TInstant *': t_converted = _ffi.cast('TimestampTz', t) result = _lib.tintinst_make(i, t_converted) + _check_error() return result if result != _ffi.NULL else None def tintseq_from_base_period(i: int, p: 'const Span *') -> 'TSequence *': p_converted = _ffi.cast('const Span *', p) result = _lib.tintseq_from_base_period(i, p_converted) + _check_error() return result if result != _ffi.NULL else None def tintseq_from_base_timestampset(i: int, ts: 'const Set *') -> 'TSequence *': ts_converted = _ffi.cast('const Set *', ts) result = _lib.tintseq_from_base_timestampset(i, ts_converted) + _check_error() return result if result != _ffi.NULL else None def tintseqset_from_base_periodset(i: int, ps: 'const SpanSet *') -> 'TSequenceSet *': ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.tintseqset_from_base_periodset(i, ps_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3884,6 +4451,7 @@ def tsequence_make(instants: 'const TInstant **', count: int, lower_inc: bool, u instants_converted = [_ffi.cast('const TInstant *', x) for x in instants] interp_converted = _ffi.cast('interpType', interp) result = _lib.tsequence_make(instants_converted, count, lower_inc, upper_inc, interp_converted, normalize) + _check_error() return result if result != _ffi.NULL else None @@ -3891,18 +4459,21 @@ def tsequence_make_exp(instants: 'const TInstant **', count: int, maxcount: int, instants_converted = [_ffi.cast('const TInstant *', x) for x in instants] interp_converted = _ffi.cast('interpType', interp) result = _lib.tsequence_make_exp(instants_converted, count, maxcount, lower_inc, upper_inc, interp_converted, normalize) + _check_error() return result if result != _ffi.NULL else None def tsequenceset_make(sequences: 'const TSequence **', count: int, normalize: bool) -> 'TSequenceSet *': sequences_converted = [_ffi.cast('const TSequence *', x) for x in sequences] result = _lib.tsequenceset_make(sequences_converted, count, normalize) + _check_error() return result if result != _ffi.NULL else None def tsequenceset_make_exp(sequences: 'const TSequence **', count: int, maxcount: int, normalize: bool) -> 'TSequenceSet *': sequences_converted = [_ffi.cast('const TSequence *', x) for x in sequences] result = _lib.tsequenceset_make_exp(sequences_converted, count, maxcount, normalize) + _check_error() return result if result != _ffi.NULL else None @@ -3911,6 +4482,7 @@ def tsequenceset_make_gaps(instants: 'const TInstant **', count: int, interp: 'i interp_converted = _ffi.cast('interpType', interp) maxt_converted = _ffi.cast('Interval *', maxt) result = _lib.tsequenceset_make_gaps(instants_converted, count, interp_converted, maxt_converted, maxdist) + _check_error() return result if result != _ffi.NULL else None @@ -3918,6 +4490,7 @@ def ttext_from_base_temp(txt: str, temp: 'const Temporal *') -> 'Temporal *': txt_converted = cstring2text(txt) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.ttext_from_base_temp(txt_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3925,6 +4498,7 @@ def ttextinst_make(txt: str, t: int) -> 'TInstant *': txt_converted = cstring2text(txt) t_converted = _ffi.cast('TimestampTz', t) result = _lib.ttextinst_make(txt_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3932,6 +4506,7 @@ def ttextseq_from_base_period(txt: str, p: 'const Span *') -> 'TSequence *': txt_converted = cstring2text(txt) p_converted = _ffi.cast('const Span *', p) result = _lib.ttextseq_from_base_period(txt_converted, p_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3939,6 +4514,7 @@ def ttextseq_from_base_timestampset(txt: str, ts: 'const Set *') -> 'TSequence * txt_converted = cstring2text(txt) ts_converted = _ffi.cast('const Set *', ts) result = _lib.ttextseq_from_base_timestampset(txt_converted, ts_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3946,42 +4522,49 @@ def ttextseqset_from_base_periodset(txt: str, ps: 'const SpanSet *') -> 'TSequen txt_converted = cstring2text(txt) ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.ttextseqset_from_base_periodset(txt_converted, ps_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_to_period(temp: 'const Temporal *') -> 'Span *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_to_period(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tfloat_to_tint(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_to_tint(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tint_to_tfloat(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_to_tfloat(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tnumber_to_span(temp: 'const Temporal *') -> 'Span *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tnumber_to_span(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tbool_end_value(temp: 'const Temporal *') -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tbool_end_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tbool_start_value(temp: 'const Temporal *') -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tbool_start_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -3989,42 +4572,49 @@ def tbool_values(temp: 'const Temporal *') -> "Tuple['bool *', 'int']": temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.tbool_values(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] def temporal_duration(temp: 'const Temporal *', boundspan: bool) -> 'Interval *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_duration(temp_converted, boundspan) + _check_error() return result if result != _ffi.NULL else None def temporal_end_instant(temp: 'const Temporal *') -> 'const TInstant *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_end_instant(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_end_sequence(temp: 'const Temporal *') -> 'TSequence *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_end_sequence(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_end_timestamp(temp: 'const Temporal *') -> 'TimestampTz': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_end_timestamp(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_hash(temp: 'const Temporal *') -> 'uint32': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_hash(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_instant_n(temp: 'const Temporal *', n: int) -> 'const TInstant *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_instant_n(temp_converted, n) + _check_error() return result if result != _ffi.NULL else None @@ -4032,12 +4622,14 @@ def temporal_instants(temp: 'const Temporal *') -> "Tuple['const TInstant **', ' temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.temporal_instants(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] def temporal_interp(temp: 'const Temporal *') -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_interp(temp_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -4045,30 +4637,35 @@ def temporal_interp(temp: 'const Temporal *') -> str: def temporal_max_instant(temp: 'const Temporal *') -> 'const TInstant *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_max_instant(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_min_instant(temp: 'const Temporal *') -> 'const TInstant *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_min_instant(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_num_instants(temp: 'const Temporal *') -> 'int': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_num_instants(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_num_sequences(temp: 'const Temporal *') -> 'int': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_num_sequences(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_num_timestamps(temp: 'const Temporal *') -> 'int': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_num_timestamps(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4076,12 +4673,14 @@ def temporal_segments(temp: 'const Temporal *') -> "Tuple['TSequence **', 'int'] temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.temporal_segments(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] def temporal_sequence_n(temp: 'const Temporal *', i: int) -> 'TSequence *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_sequence_n(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -4089,24 +4688,28 @@ def temporal_sequences(temp: 'const Temporal *') -> "Tuple['TSequence **', 'int' temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.temporal_sequences(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] def temporal_start_instant(temp: 'const Temporal *') -> 'const TInstant *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_start_instant(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_start_sequence(temp: 'const Temporal *') -> 'TSequence *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_start_sequence(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_start_timestamp(temp: 'const Temporal *') -> 'TimestampTz': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_start_timestamp(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4114,12 +4717,14 @@ def temporal_stops(temp: 'const Temporal *', maxdist: float, minduration: 'const temp_converted = _ffi.cast('const Temporal *', temp) minduration_converted = _ffi.cast('const Interval *', minduration) result = _lib.temporal_stops(temp_converted, maxdist, minduration_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_subtype(temp: 'const Temporal *') -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_subtype(temp_converted) + _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -4127,6 +4732,7 @@ def temporal_subtype(temp: 'const Temporal *') -> str: def temporal_time(temp: 'const Temporal *') -> 'SpanSet *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_time(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4134,6 +4740,7 @@ def temporal_timestamp_n(temp: 'const Temporal *', n: int) -> int: temp_converted = _ffi.cast('const Temporal *', temp) out_result = _ffi.new('TimestampTz *') result = _lib.temporal_timestamp_n(temp_converted, n, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -4143,6 +4750,7 @@ def temporal_timestamps(temp: 'const Temporal *') -> "Tuple['TimestampTz *', 'in temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.temporal_timestamps(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] @@ -4150,30 +4758,35 @@ def temporal_values(temp: 'const Temporal *') -> "Tuple['Datum *', 'int']": temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.temporal_values(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] def tfloat_end_value(temp: 'const Temporal *') -> 'double': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_end_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tfloat_max_value(temp: 'const Temporal *') -> 'double': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_max_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tfloat_min_value(temp: 'const Temporal *') -> 'double': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_min_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tfloat_start_value(temp: 'const Temporal *') -> 'double': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_start_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4181,30 +4794,35 @@ def tfloat_values(temp: 'const Temporal *') -> "Tuple['double *', 'int']": temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.tfloat_values(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] def tint_end_value(temp: 'const Temporal *') -> 'int': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_end_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tint_max_value(temp: 'const Temporal *') -> 'int': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_max_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tint_min_value(temp: 'const Temporal *') -> 'int': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_min_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tint_start_value(temp: 'const Temporal *') -> 'int': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_start_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4212,24 +4830,28 @@ def tint_values(temp: 'const Temporal *') -> "Tuple['int *', 'int']": temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.tint_values(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] def tnumber_valuespans(temp: 'const Temporal *') -> 'SpanSet *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tnumber_valuespans(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_end_value(temp: 'const Temporal *') -> 'GSERIALIZED *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_end_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_start_value(temp: 'const Temporal *') -> 'GSERIALIZED *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_start_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4237,12 +4859,14 @@ def tpoint_values(temp: 'const Temporal *') -> "Tuple['GSERIALIZED **', 'int']": temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.tpoint_values(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] def ttext_end_value(temp: 'const Temporal *') -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.ttext_end_value(temp_converted) + _check_error() result = text2cstring(result) return result if result != _ffi.NULL else None @@ -4250,6 +4874,7 @@ def ttext_end_value(temp: 'const Temporal *') -> str: def ttext_max_value(temp: 'const Temporal *') -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.ttext_max_value(temp_converted) + _check_error() result = text2cstring(result) return result if result != _ffi.NULL else None @@ -4257,6 +4882,7 @@ def ttext_max_value(temp: 'const Temporal *') -> str: def ttext_min_value(temp: 'const Temporal *') -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.ttext_min_value(temp_converted) + _check_error() result = text2cstring(result) return result if result != _ffi.NULL else None @@ -4264,6 +4890,7 @@ def ttext_min_value(temp: 'const Temporal *') -> str: def ttext_start_value(temp: 'const Temporal *') -> str: temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.ttext_start_value(temp_converted) + _check_error() result = text2cstring(result) return result if result != _ffi.NULL else None @@ -4272,6 +4899,7 @@ def ttext_values(temp: 'const Temporal *') -> "Tuple['text **', 'int']": temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.ttext_values(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] @@ -4279,6 +4907,7 @@ def temporal_set_interp(temp: 'const Temporal *', interp: 'interpType') -> 'Temp temp_converted = _ffi.cast('const Temporal *', temp) interp_converted = _ffi.cast('interpType', interp) result = _lib.temporal_set_interp(temp_converted, interp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4286,6 +4915,7 @@ def temporal_shift(temp: 'const Temporal *', shift: 'const Interval *') -> 'Temp temp_converted = _ffi.cast('const Temporal *', temp) shift_converted = _ffi.cast('const Interval *', shift) result = _lib.temporal_shift(temp_converted, shift_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4294,24 +4924,28 @@ def temporal_shift_tscale(temp: 'const Temporal *', shift: "Optional['const Inte shift_converted = _ffi.cast('const Interval *', shift) if shift is not None else _ffi.NULL duration_converted = _ffi.cast('const Interval *', duration) if duration is not None else _ffi.NULL result = _lib.temporal_shift_tscale(temp_converted, shift_converted, duration_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_to_tinstant(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_to_tinstant(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_to_tsequence(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_to_tsequence(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_to_tsequenceset(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_to_tsequenceset(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4320,6 +4954,7 @@ def temporal_tprecision(temp: 'const Temporal *', duration: 'const Interval *', duration_converted = _ffi.cast('const Interval *', duration) origin_converted = _ffi.cast('TimestampTz', origin) result = _lib.temporal_tprecision(temp_converted, duration_converted, origin_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4328,6 +4963,7 @@ def temporal_tsample(temp: 'const Temporal *', duration: 'const Interval *', ori duration_converted = _ffi.cast('const Interval *', duration) origin_converted = _ffi.cast('TimestampTz', origin) result = _lib.temporal_tsample(temp_converted, duration_converted, origin_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4335,18 +4971,21 @@ def temporal_tscale(temp: 'const Temporal *', duration: 'const Interval *') -> ' temp_converted = _ffi.cast('const Temporal *', temp) duration_converted = _ffi.cast('const Interval *', duration) result = _lib.temporal_tscale(temp_converted, duration_converted) + _check_error() return result if result != _ffi.NULL else None def tbool_at_value(temp: 'const Temporal *', b: bool) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tbool_at_value(temp_converted, b) + _check_error() return result if result != _ffi.NULL else None def tbool_minus_value(temp: 'const Temporal *', b: bool) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tbool_minus_value(temp_converted, b) + _check_error() return result if result != _ffi.NULL else None @@ -4355,6 +4994,7 @@ def tbool_value_at_timestamp(temp: 'const Temporal *', t: int, strict: bool) -> t_converted = _ffi.cast('TimestampTz', t) out_result = _ffi.new('bool *') result = _lib.tbool_value_at_timestamp(temp_converted, t_converted, strict, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -4363,12 +5003,14 @@ def tbool_value_at_timestamp(temp: 'const Temporal *', t: int, strict: bool) -> def temporal_at_max(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_at_max(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_at_min(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_at_min(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4376,6 +5018,7 @@ def temporal_at_period(temp: 'const Temporal *', p: 'const Span *') -> 'Temporal temp_converted = _ffi.cast('const Temporal *', temp) p_converted = _ffi.cast('const Span *', p) result = _lib.temporal_at_period(temp_converted, p_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4383,6 +5026,7 @@ def temporal_at_periodset(temp: 'const Temporal *', ps: 'const SpanSet *') -> 'T temp_converted = _ffi.cast('const Temporal *', temp) ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.temporal_at_periodset(temp_converted, ps_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4390,6 +5034,7 @@ def temporal_at_timestamp(temp: 'const Temporal *', t: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) t_converted = _ffi.cast('TimestampTz', t) result = _lib.temporal_at_timestamp(temp_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4397,6 +5042,7 @@ def temporal_at_timestampset(temp: 'const Temporal *', ts: 'const Set *') -> 'Te temp_converted = _ffi.cast('const Temporal *', temp) ts_converted = _ffi.cast('const Set *', ts) result = _lib.temporal_at_timestampset(temp_converted, ts_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4404,18 +5050,21 @@ def temporal_at_values(temp: 'const Temporal *', set: 'const Set *') -> 'Tempora temp_converted = _ffi.cast('const Temporal *', temp) set_converted = _ffi.cast('const Set *', set) result = _lib.temporal_at_values(temp_converted, set_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_minus_max(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_minus_max(temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_minus_min(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_minus_min(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4423,6 +5072,7 @@ def temporal_minus_period(temp: 'const Temporal *', p: 'const Span *') -> 'Tempo temp_converted = _ffi.cast('const Temporal *', temp) p_converted = _ffi.cast('const Span *', p) result = _lib.temporal_minus_period(temp_converted, p_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4430,6 +5080,7 @@ def temporal_minus_periodset(temp: 'const Temporal *', ps: 'const SpanSet *') -> temp_converted = _ffi.cast('const Temporal *', temp) ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.temporal_minus_periodset(temp_converted, ps_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4437,6 +5088,7 @@ def temporal_minus_timestamp(temp: 'const Temporal *', t: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) t_converted = _ffi.cast('TimestampTz', t) result = _lib.temporal_minus_timestamp(temp_converted, t_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4444,6 +5096,7 @@ def temporal_minus_timestampset(temp: 'const Temporal *', ts: 'const Set *') -> temp_converted = _ffi.cast('const Temporal *', temp) ts_converted = _ffi.cast('const Set *', ts) result = _lib.temporal_minus_timestampset(temp_converted, ts_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4451,18 +5104,21 @@ def temporal_minus_values(temp: 'const Temporal *', set: 'const Set *') -> 'Temp temp_converted = _ffi.cast('const Temporal *', temp) set_converted = _ffi.cast('const Set *', set) result = _lib.temporal_minus_values(temp_converted, set_converted) + _check_error() return result if result != _ffi.NULL else None def tfloat_at_value(temp: 'const Temporal *', d: float) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_at_value(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def tfloat_minus_value(temp: 'const Temporal *', d: float) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_minus_value(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None @@ -4471,6 +5127,7 @@ def tfloat_value_at_timestamp(temp: 'const Temporal *', t: int, strict: bool) -> t_converted = _ffi.cast('TimestampTz', t) out_result = _ffi.new('double *') result = _lib.tfloat_value_at_timestamp(temp_converted, t_converted, strict, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -4479,12 +5136,14 @@ def tfloat_value_at_timestamp(temp: 'const Temporal *', t: int, strict: bool) -> def tint_at_value(temp: 'const Temporal *', i: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_at_value(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None def tint_minus_value(temp: 'const Temporal *', i: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_minus_value(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -4493,6 +5152,7 @@ def tint_value_at_timestamp(temp: 'const Temporal *', t: int, strict: bool) -> ' t_converted = _ffi.cast('TimestampTz', t) out_result = _ffi.new('int *') result = _lib.tint_value_at_timestamp(temp_converted, t_converted, strict, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -4502,6 +5162,7 @@ def tnumber_at_span(temp: 'const Temporal *', span: 'const Span *') -> 'Temporal temp_converted = _ffi.cast('const Temporal *', temp) span_converted = _ffi.cast('const Span *', span) result = _lib.tnumber_at_span(temp_converted, span_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4509,6 +5170,7 @@ def tnumber_at_spanset(temp: 'const Temporal *', ss: 'const SpanSet *') -> 'Temp temp_converted = _ffi.cast('const Temporal *', temp) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.tnumber_at_spanset(temp_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4516,6 +5178,7 @@ def tnumber_at_tbox(temp: 'const Temporal *', box: 'const TBox *') -> 'Temporal temp_converted = _ffi.cast('const Temporal *', temp) box_converted = _ffi.cast('const TBox *', box) result = _lib.tnumber_at_tbox(temp_converted, box_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4523,6 +5186,7 @@ def tnumber_minus_span(temp: 'const Temporal *', span: 'const Span *') -> 'Tempo temp_converted = _ffi.cast('const Temporal *', temp) span_converted = _ffi.cast('const Span *', span) result = _lib.tnumber_minus_span(temp_converted, span_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4530,6 +5194,7 @@ def tnumber_minus_spanset(temp: 'const Temporal *', ss: 'const SpanSet *') -> 'T temp_converted = _ffi.cast('const Temporal *', temp) ss_converted = _ffi.cast('const SpanSet *', ss) result = _lib.tnumber_minus_spanset(temp_converted, ss_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4537,6 +5202,7 @@ def tnumber_minus_tbox(temp: 'const Temporal *', box: 'const TBox *') -> 'Tempor temp_converted = _ffi.cast('const Temporal *', temp) box_converted = _ffi.cast('const TBox *', box) result = _lib.tnumber_minus_tbox(temp_converted, box_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4546,6 +5212,7 @@ def tpoint_at_geom_time(temp: 'const Temporal *', gs: 'const GSERIALIZED *', zsp zspan_converted = _ffi.cast('const Span *', zspan) period_converted = _ffi.cast('const Span *', period) result = _lib.tpoint_at_geom_time(temp_converted, gs_converted, zspan_converted, period_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4553,6 +5220,7 @@ def tpoint_at_stbox(temp: 'const Temporal *', box: 'const STBox *', border_inc: temp_converted = _ffi.cast('const Temporal *', temp) box_converted = _ffi.cast('const STBox *', box) result = _lib.tpoint_at_stbox(temp_converted, box_converted, border_inc) + _check_error() return result if result != _ffi.NULL else None @@ -4560,6 +5228,7 @@ def tpoint_at_value(temp: 'const Temporal *', gs: 'GSERIALIZED *') -> 'Temporal temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('GSERIALIZED *', gs) result = _lib.tpoint_at_value(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4569,6 +5238,7 @@ def tpoint_minus_geom_time(temp: 'const Temporal *', gs: 'const GSERIALIZED *', zspan_converted = _ffi.cast('const Span *', zspan) period_converted = _ffi.cast('const Span *', period) result = _lib.tpoint_minus_geom_time(temp_converted, gs_converted, zspan_converted, period_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4576,6 +5246,7 @@ def tpoint_minus_stbox(temp: 'const Temporal *', box: 'const STBox *', border_in temp_converted = _ffi.cast('const Temporal *', temp) box_converted = _ffi.cast('const STBox *', box) result = _lib.tpoint_minus_stbox(temp_converted, box_converted, border_inc) + _check_error() return result if result != _ffi.NULL else None @@ -4583,6 +5254,7 @@ def tpoint_minus_value(temp: 'const Temporal *', gs: 'GSERIALIZED *') -> 'Tempor temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('GSERIALIZED *', gs) result = _lib.tpoint_minus_value(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4591,6 +5263,7 @@ def tpoint_value_at_timestamp(temp: 'const Temporal *', t: int, strict: bool) -> t_converted = _ffi.cast('TimestampTz', t) out_result = _ffi.new('GSERIALIZED **') result = _lib.tpoint_value_at_timestamp(temp_converted, t_converted, strict, out_result) + _check_error() if result: return out_result if out_result != _ffi.NULL else None return None @@ -4600,6 +5273,7 @@ def ttext_at_value(temp: 'const Temporal *', txt: str) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.ttext_at_value(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4607,6 +5281,7 @@ def ttext_minus_value(temp: 'const Temporal *', txt: str) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.ttext_minus_value(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4615,6 +5290,7 @@ def ttext_value_at_timestamp(temp: 'const Temporal *', t: int, strict: bool) -> t_converted = _ffi.cast('TimestampTz', t) out_result = _ffi.new('text **') result = _lib.ttext_value_at_timestamp(temp_converted, t_converted, strict, out_result) + _check_error() if result: return out_result if out_result != _ffi.NULL else None return None @@ -4625,6 +5301,7 @@ def temporal_append_tinstant(temp: 'Temporal *', inst: 'const TInstant *', maxdi inst_converted = _ffi.cast('const TInstant *', inst) maxt_converted = _ffi.cast('Interval *', maxt) if maxt is not None else _ffi.NULL result = _lib.temporal_append_tinstant(temp_converted, inst_converted, maxdist, maxt_converted, expand) + _check_error() return result if result != _ffi.NULL else None @@ -4632,6 +5309,7 @@ def temporal_append_tsequence(temp: 'Temporal *', seq: 'const TSequence *', expa temp_converted = _ffi.cast('Temporal *', temp) seq_converted = _ffi.cast('const TSequence *', seq) result = _lib.temporal_append_tsequence(temp_converted, seq_converted, expand) + _check_error() return result if result != _ffi.NULL else None @@ -4639,6 +5317,7 @@ def temporal_delete_period(temp: 'const Temporal *', p: 'const Span *', connect: temp_converted = _ffi.cast('const Temporal *', temp) p_converted = _ffi.cast('const Span *', p) result = _lib.temporal_delete_period(temp_converted, p_converted, connect) + _check_error() return result if result != _ffi.NULL else None @@ -4646,6 +5325,7 @@ def temporal_delete_periodset(temp: 'const Temporal *', ps: 'const SpanSet *', c temp_converted = _ffi.cast('const Temporal *', temp) ps_converted = _ffi.cast('const SpanSet *', ps) result = _lib.temporal_delete_periodset(temp_converted, ps_converted, connect) + _check_error() return result if result != _ffi.NULL else None @@ -4653,6 +5333,7 @@ def temporal_delete_timestamp(temp: 'const Temporal *', t: int, connect: bool) - temp_converted = _ffi.cast('const Temporal *', temp) t_converted = _ffi.cast('TimestampTz', t) result = _lib.temporal_delete_timestamp(temp_converted, t_converted, connect) + _check_error() return result if result != _ffi.NULL else None @@ -4660,6 +5341,7 @@ def temporal_delete_timestampset(temp: 'const Temporal *', ts: 'const Set *', co temp_converted = _ffi.cast('const Temporal *', temp) ts_converted = _ffi.cast('const Set *', ts) result = _lib.temporal_delete_timestampset(temp_converted, ts_converted, connect) + _check_error() return result if result != _ffi.NULL else None @@ -4667,6 +5349,7 @@ def temporal_insert(temp1: 'const Temporal *', temp2: 'const Temporal *', connec temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_insert(temp1_converted, temp2_converted, connect) + _check_error() return result if result != _ffi.NULL else None @@ -4674,12 +5357,14 @@ def temporal_merge(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'Tem temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_merge(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_merge_array(temparr: 'Temporal **', count: int) -> 'Temporal *': temparr_converted = [_ffi.cast('Temporal *', x) for x in temparr] result = _lib.temporal_merge_array(temparr_converted, count) + _check_error() return result if result != _ffi.NULL else None @@ -4687,18 +5372,21 @@ def temporal_update(temp1: 'const Temporal *', temp2: 'const Temporal *', connec temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_update(temp1_converted, temp2_converted, connect) + _check_error() return result if result != _ffi.NULL else None def tand_bool_tbool(b: bool, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tand_bool_tbool(b, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tand_tbool_bool(temp: 'const Temporal *', b: bool) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tand_tbool_bool(temp_converted, b) + _check_error() return result if result != _ffi.NULL else None @@ -4706,30 +5394,35 @@ def tand_tbool_tbool(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'T temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.tand_tbool_tbool(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None def tbool_when_true(temp: 'const Temporal *') -> 'SpanSet *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tbool_when_true(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tnot_tbool(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tnot_tbool(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tor_bool_tbool(b: bool, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tor_bool_tbool(b, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tor_tbool_bool(temp: 'const Temporal *', b: bool) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tor_tbool_bool(temp_converted, b) + _check_error() return result if result != _ffi.NULL else None @@ -4737,30 +5430,35 @@ def tor_tbool_tbool(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'Te temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.tor_tbool_tbool(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None def add_float_tfloat(d: float, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.add_float_tfloat(d, tnumber_converted) + _check_error() return result if result != _ffi.NULL else None def add_int_tint(i: int, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.add_int_tint(i, tnumber_converted) + _check_error() return result if result != _ffi.NULL else None def add_tfloat_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.add_tfloat_float(tnumber_converted, d) + _check_error() return result if result != _ffi.NULL else None def add_tint_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.add_tint_int(tnumber_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -4768,30 +5466,35 @@ def add_tnumber_tnumber(tnumber1: 'const Temporal *', tnumber2: 'const Temporal tnumber1_converted = _ffi.cast('const Temporal *', tnumber1) tnumber2_converted = _ffi.cast('const Temporal *', tnumber2) result = _lib.add_tnumber_tnumber(tnumber1_converted, tnumber2_converted) + _check_error() return result if result != _ffi.NULL else None def div_float_tfloat(d: float, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.div_float_tfloat(d, tnumber_converted) + _check_error() return result if result != _ffi.NULL else None def div_int_tint(i: int, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.div_int_tint(i, tnumber_converted) + _check_error() return result if result != _ffi.NULL else None def div_tfloat_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.div_tfloat_float(tnumber_converted, d) + _check_error() return result if result != _ffi.NULL else None def div_tint_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.div_tint_int(tnumber_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -4799,35 +5502,41 @@ def div_tnumber_tnumber(tnumber1: 'const Temporal *', tnumber2: 'const Temporal tnumber1_converted = _ffi.cast('const Temporal *', tnumber1) tnumber2_converted = _ffi.cast('const Temporal *', tnumber2) result = _lib.div_tnumber_tnumber(tnumber1_converted, tnumber2_converted) + _check_error() return result if result != _ffi.NULL else None def float_degrees(value: float, normalize: bool) -> 'double': result = _lib.float_degrees(value, normalize) + _check_error() return result if result != _ffi.NULL else None def mult_float_tfloat(d: float, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.mult_float_tfloat(d, tnumber_converted) + _check_error() return result if result != _ffi.NULL else None def mult_int_tint(i: int, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.mult_int_tint(i, tnumber_converted) + _check_error() return result if result != _ffi.NULL else None def mult_tfloat_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.mult_tfloat_float(tnumber_converted, d) + _check_error() return result if result != _ffi.NULL else None def mult_tint_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.mult_tint_int(tnumber_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -4835,30 +5544,35 @@ def mult_tnumber_tnumber(tnumber1: 'const Temporal *', tnumber2: 'const Temporal tnumber1_converted = _ffi.cast('const Temporal *', tnumber1) tnumber2_converted = _ffi.cast('const Temporal *', tnumber2) result = _lib.mult_tnumber_tnumber(tnumber1_converted, tnumber2_converted) + _check_error() return result if result != _ffi.NULL else None def sub_float_tfloat(d: float, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.sub_float_tfloat(d, tnumber_converted) + _check_error() return result if result != _ffi.NULL else None def sub_int_tint(i: int, tnumber: 'const Temporal *') -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.sub_int_tint(i, tnumber_converted) + _check_error() return result if result != _ffi.NULL else None def sub_tfloat_float(tnumber: 'const Temporal *', d: float) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.sub_tfloat_float(tnumber_converted, d) + _check_error() return result if result != _ffi.NULL else None def sub_tint_int(tnumber: 'const Temporal *', i: int) -> 'Temporal *': tnumber_converted = _ffi.cast('const Temporal *', tnumber) result = _lib.sub_tint_int(tnumber_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -4866,48 +5580,56 @@ def sub_tnumber_tnumber(tnumber1: 'const Temporal *', tnumber2: 'const Temporal tnumber1_converted = _ffi.cast('const Temporal *', tnumber1) tnumber2_converted = _ffi.cast('const Temporal *', tnumber2) result = _lib.sub_tnumber_tnumber(tnumber1_converted, tnumber2_converted) + _check_error() return result if result != _ffi.NULL else None def tfloat_round(temp: 'const Temporal *', maxdd: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_round(temp_converted, maxdd) + _check_error() return result if result != _ffi.NULL else None def tfloat_degrees(temp: 'const Temporal *', normalize: bool) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_degrees(temp_converted, normalize) + _check_error() return result if result != _ffi.NULL else None def tfloat_derivative(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_derivative(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tfloat_radians(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_radians(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tnumber_abs(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tnumber_abs(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tnumber_angular_difference(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tnumber_angular_difference(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tnumber_delta_value(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tnumber_delta_value(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4915,6 +5637,7 @@ def textcat_text_ttext(txt: str, temp: 'const Temporal *') -> 'Temporal *': txt_converted = cstring2text(txt) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.textcat_text_ttext(txt_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4922,6 +5645,7 @@ def textcat_ttext_text(temp: 'const Temporal *', txt: str) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.textcat_ttext_text(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4929,30 +5653,35 @@ def textcat_ttext_ttext(temp1: 'const Temporal *', temp2: 'const Temporal *') -> temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.textcat_ttext_ttext(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None def ttext_upper(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.ttext_upper(temp_converted) + _check_error() return result if result != _ffi.NULL else None def ttext_lower(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.ttext_lower(temp_converted) + _check_error() return result if result != _ffi.NULL else None def distance_tfloat_float(temp: 'const Temporal *', d: float) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.distance_tfloat_float(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def distance_tint_int(temp: 'const Temporal *', i: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.distance_tint_int(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -4960,6 +5689,7 @@ def distance_tnumber_tnumber(temp1: 'const Temporal *', temp2: 'const Temporal * temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.distance_tnumber_tnumber(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4967,6 +5697,7 @@ def distance_tpoint_geo(temp: 'const Temporal *', geo: 'const GSERIALIZED *') -> temp_converted = _ffi.cast('const Temporal *', temp) geo_converted = _ffi.cast('const GSERIALIZED *', geo) result = _lib.distance_tpoint_geo(temp_converted, geo_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4974,6 +5705,7 @@ def distance_tpoint_tpoint(temp1: 'const Temporal *', temp2: 'const Temporal *') temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.distance_tpoint_tpoint(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4981,6 +5713,7 @@ def nad_stbox_geo(box: 'const STBox *', gs: 'const GSERIALIZED *') -> 'double': box_converted = _ffi.cast('const STBox *', box) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.nad_stbox_geo(box_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4988,6 +5721,7 @@ def nad_stbox_stbox(box1: 'const STBox *', box2: 'const STBox *') -> 'double': box1_converted = _ffi.cast('const STBox *', box1) box2_converted = _ffi.cast('const STBox *', box2) result = _lib.nad_stbox_stbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -4995,12 +5729,14 @@ def nad_tbox_tbox(box1: 'const TBox *', box2: 'const TBox *') -> 'double': box1_converted = _ffi.cast('const TBox *', box1) box2_converted = _ffi.cast('const TBox *', box2) result = _lib.nad_tbox_tbox(box1_converted, box2_converted) + _check_error() return result if result != _ffi.NULL else None def nad_tfloat_float(temp: 'const Temporal *', d: float) -> 'double': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.nad_tfloat_float(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None @@ -5008,12 +5744,14 @@ def nad_tfloat_tfloat(temp1: 'const Temporal *', temp2: 'const Temporal *') -> ' temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.nad_tfloat_tfloat(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None def nad_tint_int(temp: 'const Temporal *', i: int) -> 'int': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.nad_tint_int(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -5021,6 +5759,7 @@ def nad_tint_tint(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'int' temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.nad_tint_tint(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5028,6 +5767,7 @@ def nad_tnumber_tbox(temp: 'const Temporal *', box: 'const TBox *') -> 'double': temp_converted = _ffi.cast('const Temporal *', temp) box_converted = _ffi.cast('const TBox *', box) result = _lib.nad_tnumber_tbox(temp_converted, box_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5035,6 +5775,7 @@ def nad_tpoint_geo(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> 'doub temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.nad_tpoint_geo(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5042,6 +5783,7 @@ def nad_tpoint_stbox(temp: 'const Temporal *', box: 'const STBox *') -> 'double' temp_converted = _ffi.cast('const Temporal *', temp) box_converted = _ffi.cast('const STBox *', box) result = _lib.nad_tpoint_stbox(temp_converted, box_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5049,6 +5791,7 @@ def nad_tpoint_tpoint(temp1: 'const Temporal *', temp2: 'const Temporal *') -> ' temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.nad_tpoint_tpoint(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5056,6 +5799,7 @@ def nai_tpoint_geo(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> 'TIns temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.nai_tpoint_geo(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5063,6 +5807,7 @@ def nai_tpoint_tpoint(temp1: 'const Temporal *', temp2: 'const Temporal *') -> ' temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.nai_tpoint_tpoint(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5071,6 +5816,7 @@ def shortestline_tpoint_geo(temp: 'const Temporal *', gs: 'const GSERIALIZED *') gs_converted = _ffi.cast('const GSERIALIZED *', gs) out_result = _ffi.new('GSERIALIZED **') result = _lib.shortestline_tpoint_geo(temp_converted, gs_converted, out_result) + _check_error() if result: return out_result if out_result != _ffi.NULL else None return None @@ -5081,6 +5827,7 @@ def shortestline_tpoint_tpoint(temp1: 'const Temporal *', temp2: 'const Temporal temp2_converted = _ffi.cast('const Temporal *', temp2) out_result = _ffi.new('GSERIALIZED **') result = _lib.shortestline_tpoint_tpoint(temp1_converted, temp2_converted, out_result) + _check_error() if result: return out_result if out_result != _ffi.NULL else None return None @@ -5089,48 +5836,56 @@ def shortestline_tpoint_tpoint(temp1: 'const Temporal *', temp2: 'const Temporal def tbool_always_eq(temp: 'const Temporal *', b: bool) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tbool_always_eq(temp_converted, b) + _check_error() return result if result != _ffi.NULL else None def tbool_ever_eq(temp: 'const Temporal *', b: bool) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tbool_ever_eq(temp_converted, b) + _check_error() return result if result != _ffi.NULL else None def tfloat_always_eq(temp: 'const Temporal *', d: float) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_always_eq(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def tfloat_always_le(temp: 'const Temporal *', d: float) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_always_le(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def tfloat_always_lt(temp: 'const Temporal *', d: float) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_always_lt(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def tfloat_ever_eq(temp: 'const Temporal *', d: float) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_ever_eq(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def tfloat_ever_le(temp: 'const Temporal *', d: float) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_ever_le(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def tfloat_ever_lt(temp: 'const Temporal *', d: float) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_ever_lt(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None @@ -5138,6 +5893,7 @@ def tgeogpoint_always_eq(temp: 'const Temporal *', gs: 'GSERIALIZED *') -> 'bool temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('GSERIALIZED *', gs) result = _lib.tgeogpoint_always_eq(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5145,6 +5901,7 @@ def tgeogpoint_ever_eq(temp: 'const Temporal *', gs: 'GSERIALIZED *') -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('GSERIALIZED *', gs) result = _lib.tgeogpoint_ever_eq(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5152,6 +5909,7 @@ def tgeompoint_always_eq(temp: 'const Temporal *', gs: 'GSERIALIZED *') -> 'bool temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('GSERIALIZED *', gs) result = _lib.tgeompoint_always_eq(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5159,42 +5917,49 @@ def tgeompoint_ever_eq(temp: 'const Temporal *', gs: 'GSERIALIZED *') -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('GSERIALIZED *', gs) result = _lib.tgeompoint_ever_eq(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None def tint_always_eq(temp: 'const Temporal *', i: int) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_always_eq(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None def tint_always_le(temp: 'const Temporal *', i: int) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_always_le(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None def tint_always_lt(temp: 'const Temporal *', i: int) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_always_lt(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None def tint_ever_eq(temp: 'const Temporal *', i: int) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_ever_eq(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None def tint_ever_le(temp: 'const Temporal *', i: int) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_ever_le(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None def tint_ever_lt(temp: 'const Temporal *', i: int) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_ever_lt(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -5202,6 +5967,7 @@ def tpoint_always_eq(temp: 'const Temporal *', value: 'Datum') -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) value_converted = _ffi.cast('Datum', value) result = _lib.tpoint_always_eq(temp_converted, value_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5209,6 +5975,7 @@ def tpoint_ever_eq(temp: 'const Temporal *', value: 'Datum') -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) value_converted = _ffi.cast('Datum', value) result = _lib.tpoint_ever_eq(temp_converted, value_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5216,6 +5983,7 @@ def ttext_always_eq(temp: 'const Temporal *', txt: str) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.ttext_always_eq(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5223,6 +5991,7 @@ def ttext_always_le(temp: 'const Temporal *', txt: str) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.ttext_always_le(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5230,6 +5999,7 @@ def ttext_always_lt(temp: 'const Temporal *', txt: str) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.ttext_always_lt(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5237,6 +6007,7 @@ def ttext_ever_eq(temp: 'const Temporal *', txt: str) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.ttext_ever_eq(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5244,6 +6015,7 @@ def ttext_ever_le(temp: 'const Temporal *', txt: str) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.ttext_ever_le(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5251,6 +6023,7 @@ def ttext_ever_lt(temp: 'const Temporal *', txt: str) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.ttext_ever_lt(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5258,6 +6031,7 @@ def temporal_cmp(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'int': temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_cmp(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5265,6 +6039,7 @@ def temporal_eq(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'bool': temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_eq(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5272,6 +6047,7 @@ def temporal_ge(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'bool': temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_ge(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5279,6 +6055,7 @@ def temporal_gt(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'bool': temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_gt(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5286,6 +6063,7 @@ def temporal_le(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'bool': temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_le(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5293,6 +6071,7 @@ def temporal_lt(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'bool': temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_lt(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5300,18 +6079,21 @@ def temporal_ne(temp1: 'const Temporal *', temp2: 'const Temporal *') -> 'bool': temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_ne(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None def teq_bool_tbool(b: bool, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.teq_bool_tbool(b, temp_converted) + _check_error() return result if result != _ffi.NULL else None def teq_float_tfloat(d: float, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.teq_float_tfloat(d, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5319,12 +6101,14 @@ def teq_geo_tpoint(geo: 'const GSERIALIZED *', tpoint: 'const Temporal *') -> 'T geo_converted = _ffi.cast('const GSERIALIZED *', geo) tpoint_converted = _ffi.cast('const Temporal *', tpoint) result = _lib.teq_geo_tpoint(geo_converted, tpoint_converted) + _check_error() return result if result != _ffi.NULL else None def teq_int_tint(i: int, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.teq_int_tint(i, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5332,6 +6116,7 @@ def teq_point_tgeogpoint(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> gs_converted = _ffi.cast('const GSERIALIZED *', gs) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.teq_point_tgeogpoint(gs_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5339,12 +6124,14 @@ def teq_point_tgeompoint(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> gs_converted = _ffi.cast('const GSERIALIZED *', gs) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.teq_point_tgeompoint(gs_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def teq_tbool_bool(temp: 'const Temporal *', b: bool) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.teq_tbool_bool(temp_converted, b) + _check_error() return result if result != _ffi.NULL else None @@ -5352,6 +6139,7 @@ def teq_temporal_temporal(temp1: 'const Temporal *', temp2: 'const Temporal *') temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.teq_temporal_temporal(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5359,12 +6147,14 @@ def teq_text_ttext(txt: str, temp: 'const Temporal *') -> 'Temporal *': txt_converted = cstring2text(txt) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.teq_text_ttext(txt_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def teq_tfloat_float(temp: 'const Temporal *', d: float) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.teq_tfloat_float(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None @@ -5372,6 +6162,7 @@ def teq_tgeogpoint_point(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.teq_tgeogpoint_point(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5379,12 +6170,14 @@ def teq_tgeompoint_point(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.teq_tgeompoint_point(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None def teq_tint_int(temp: 'const Temporal *', i: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.teq_tint_int(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -5392,6 +6185,7 @@ def teq_tpoint_geo(tpoint: 'const Temporal *', geo: 'const GSERIALIZED *') -> 'T tpoint_converted = _ffi.cast('const Temporal *', tpoint) geo_converted = _ffi.cast('const GSERIALIZED *', geo) result = _lib.teq_tpoint_geo(tpoint_converted, geo_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5399,18 +6193,21 @@ def teq_ttext_text(temp: 'const Temporal *', txt: str) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.teq_ttext_text(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None def tge_float_tfloat(d: float, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tge_float_tfloat(d, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tge_int_tint(i: int, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tge_int_tint(i, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5418,6 +6215,7 @@ def tge_temporal_temporal(temp1: 'const Temporal *', temp2: 'const Temporal *') temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.tge_temporal_temporal(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5425,18 +6223,21 @@ def tge_text_ttext(txt: str, temp: 'const Temporal *') -> 'Temporal *': txt_converted = cstring2text(txt) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tge_text_ttext(txt_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tge_tfloat_float(temp: 'const Temporal *', d: float) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tge_tfloat_float(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def tge_tint_int(temp: 'const Temporal *', i: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tge_tint_int(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -5444,18 +6245,21 @@ def tge_ttext_text(temp: 'const Temporal *', txt: str) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.tge_ttext_text(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None def tgt_float_tfloat(d: float, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tgt_float_tfloat(d, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tgt_int_tint(i: int, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tgt_int_tint(i, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5463,6 +6267,7 @@ def tgt_temporal_temporal(temp1: 'const Temporal *', temp2: 'const Temporal *') temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.tgt_temporal_temporal(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5470,18 +6275,21 @@ def tgt_text_ttext(txt: str, temp: 'const Temporal *') -> 'Temporal *': txt_converted = cstring2text(txt) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tgt_text_ttext(txt_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tgt_tfloat_float(temp: 'const Temporal *', d: float) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tgt_tfloat_float(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def tgt_tint_int(temp: 'const Temporal *', i: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tgt_tint_int(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -5489,18 +6297,21 @@ def tgt_ttext_text(temp: 'const Temporal *', txt: str) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.tgt_ttext_text(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None def tle_float_tfloat(d: float, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tle_float_tfloat(d, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tle_int_tint(i: int, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tle_int_tint(i, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5508,6 +6319,7 @@ def tle_temporal_temporal(temp1: 'const Temporal *', temp2: 'const Temporal *') temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.tle_temporal_temporal(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5515,18 +6327,21 @@ def tle_text_ttext(txt: str, temp: 'const Temporal *') -> 'Temporal *': txt_converted = cstring2text(txt) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tle_text_ttext(txt_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tle_tfloat_float(temp: 'const Temporal *', d: float) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tle_tfloat_float(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def tle_tint_int(temp: 'const Temporal *', i: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tle_tint_int(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -5534,18 +6349,21 @@ def tle_ttext_text(temp: 'const Temporal *', txt: str) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.tle_ttext_text(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None def tlt_float_tfloat(d: float, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tlt_float_tfloat(d, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tlt_int_tint(i: int, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tlt_int_tint(i, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5553,6 +6371,7 @@ def tlt_temporal_temporal(temp1: 'const Temporal *', temp2: 'const Temporal *') temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.tlt_temporal_temporal(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5560,18 +6379,21 @@ def tlt_text_ttext(txt: str, temp: 'const Temporal *') -> 'Temporal *': txt_converted = cstring2text(txt) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tlt_text_ttext(txt_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tlt_tfloat_float(temp: 'const Temporal *', d: float) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tlt_tfloat_float(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def tlt_tint_int(temp: 'const Temporal *', i: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tlt_tint_int(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -5579,18 +6401,21 @@ def tlt_ttext_text(temp: 'const Temporal *', txt: str) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.tlt_ttext_text(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None def tne_bool_tbool(b: bool, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tne_bool_tbool(b, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tne_float_tfloat(d: float, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tne_float_tfloat(d, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5598,12 +6423,14 @@ def tne_geo_tpoint(geo: 'const GSERIALIZED *', tpoint: 'const Temporal *') -> 'T geo_converted = _ffi.cast('const GSERIALIZED *', geo) tpoint_converted = _ffi.cast('const Temporal *', tpoint) result = _lib.tne_geo_tpoint(geo_converted, tpoint_converted) + _check_error() return result if result != _ffi.NULL else None def tne_int_tint(i: int, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tne_int_tint(i, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5611,6 +6438,7 @@ def tne_point_tgeogpoint(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> gs_converted = _ffi.cast('const GSERIALIZED *', gs) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tne_point_tgeogpoint(gs_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5618,12 +6446,14 @@ def tne_point_tgeompoint(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> gs_converted = _ffi.cast('const GSERIALIZED *', gs) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tne_point_tgeompoint(gs_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tne_tbool_bool(temp: 'const Temporal *', b: bool) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tne_tbool_bool(temp_converted, b) + _check_error() return result if result != _ffi.NULL else None @@ -5631,6 +6461,7 @@ def tne_temporal_temporal(temp1: 'const Temporal *', temp2: 'const Temporal *') temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.tne_temporal_temporal(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5638,12 +6469,14 @@ def tne_text_ttext(txt: str, temp: 'const Temporal *') -> 'Temporal *': txt_converted = cstring2text(txt) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tne_text_ttext(txt_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tne_tfloat_float(temp: 'const Temporal *', d: float) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tne_tfloat_float(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None @@ -5651,6 +6484,7 @@ def tne_tgeogpoint_point(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.tne_tgeogpoint_point(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5658,12 +6492,14 @@ def tne_tgeompoint_point(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.tne_tgeompoint_point(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None def tne_tint_int(temp: 'const Temporal *', i: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tne_tint_int(temp_converted, i) + _check_error() return result if result != _ffi.NULL else None @@ -5671,6 +6507,7 @@ def tne_tpoint_geo(tpoint: 'const Temporal *', geo: 'const GSERIALIZED *') -> 'T tpoint_converted = _ffi.cast('const Temporal *', tpoint) geo_converted = _ffi.cast('const GSERIALIZED *', geo) result = _lib.tne_tpoint_geo(tpoint_converted, geo_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5678,6 +6515,7 @@ def tne_ttext_text(temp: 'const Temporal *', txt: str) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) result = _lib.tne_ttext_text(temp_converted, txt_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5686,6 +6524,7 @@ def bearing_point_point(geo1: 'const GSERIALIZED *', geo2: 'const GSERIALIZED *' geo2_converted = _ffi.cast('const GSERIALIZED *', geo2) out_result = _ffi.new('double *') result = _lib.bearing_point_point(geo1_converted, geo2_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -5695,6 +6534,7 @@ def bearing_tpoint_point(temp: 'const Temporal *', gs: 'const GSERIALIZED *', in temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.bearing_tpoint_point(temp_converted, gs_converted, invert) + _check_error() return result if result != _ffi.NULL else None @@ -5702,30 +6542,35 @@ def bearing_tpoint_tpoint(temp1: 'const Temporal *', temp2: 'const Temporal *') temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.bearing_tpoint_tpoint(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_angular_difference(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_angular_difference(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_azimuth(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_azimuth(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_convex_hull(temp: 'const Temporal *') -> 'GSERIALIZED *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_convex_hull(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_cumulative_length(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_cumulative_length(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5733,6 +6578,7 @@ def tpoint_direction(temp: 'const Temporal *') -> 'double': temp_converted = _ffi.cast('const Temporal *', temp) out_result = _ffi.new('double *') result = _lib.tpoint_direction(temp_converted, out_result) + _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None @@ -5741,30 +6587,35 @@ def tpoint_direction(temp: 'const Temporal *') -> 'double': def tpoint_get_coord(temp: 'const Temporal *', coord: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_get_coord(temp_converted, coord) + _check_error() return result if result != _ffi.NULL else None def tpoint_is_simple(temp: 'const Temporal *') -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_is_simple(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_length(temp: 'const Temporal *') -> 'double': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_length(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_speed(temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_speed(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_srid(temp: 'const Temporal *') -> 'int': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_srid(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5772,36 +6623,42 @@ def tpoint_stboxes(temp: 'const Temporal *') -> "Tuple['STBox *', 'int']": temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.tpoint_stboxes(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] def tpoint_trajectory(temp: 'const Temporal *') -> 'GSERIALIZED *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_trajectory(temp_converted) + _check_error() return result if result != _ffi.NULL else None def geo_expand_space(gs: 'const GSERIALIZED *', d: float) -> 'STBox *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.geo_expand_space(gs_converted, d) + _check_error() return result if result != _ffi.NULL else None def tgeompoint_tgeogpoint(temp: 'const Temporal *', oper: bool) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tgeompoint_tgeogpoint(temp_converted, oper) + _check_error() return result if result != _ffi.NULL else None def tpoint_expand_space(temp: 'const Temporal *', d: float) -> 'STBox *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_expand_space(temp_converted, d) + _check_error() return result if result != _ffi.NULL else None def tpoint_round(temp: 'const Temporal *', maxdd: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_round(temp_converted, maxdd) + _check_error() return result if result != _ffi.NULL else None @@ -5809,6 +6666,7 @@ def tpoint_make_simple(temp: 'const Temporal *') -> "Tuple['Temporal **', 'int'] temp_converted = _ffi.cast('const Temporal *', temp) count = _ffi.new('int *') result = _lib.tpoint_make_simple(temp_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] @@ -5816,6 +6674,7 @@ def tpoint_set_srid(temp: 'const Temporal *', srid: int) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) srid_converted = _ffi.cast('int32', srid) result = _lib.tpoint_set_srid(temp_converted, srid_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5823,6 +6682,7 @@ def econtains_geo_tpoint(geo: 'const GSERIALIZED *', temp: 'const Temporal *') - geo_converted = _ffi.cast('const GSERIALIZED *', geo) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.econtains_geo_tpoint(geo_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5830,6 +6690,7 @@ def edisjoint_tpoint_geo(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.edisjoint_tpoint_geo(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5837,6 +6698,7 @@ def edisjoint_tpoint_tpoint(temp1: 'const Temporal *', temp2: 'const Temporal *' temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.edisjoint_tpoint_tpoint(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5844,6 +6706,7 @@ def edwithin_tpoint_geo(temp: 'const Temporal *', gs: 'const GSERIALIZED *', dis temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.edwithin_tpoint_geo(temp_converted, gs_converted, dist) + _check_error() return result if result != _ffi.NULL else None @@ -5851,6 +6714,7 @@ def edwithin_tpoint_tpoint(temp1: 'const Temporal *', temp2: 'const Temporal *', temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.edwithin_tpoint_tpoint(temp1_converted, temp2_converted, dist) + _check_error() return result if result != _ffi.NULL else None @@ -5858,6 +6722,7 @@ def eintersects_tpoint_geo(temp: 'const Temporal *', gs: 'const GSERIALIZED *') temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.eintersects_tpoint_geo(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5865,6 +6730,7 @@ def eintersects_tpoint_tpoint(temp1: 'const Temporal *', temp2: 'const Temporal temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.eintersects_tpoint_tpoint(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5872,6 +6738,7 @@ def etouches_tpoint_geo(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.etouches_tpoint_geo(temp_converted, gs_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5879,6 +6746,7 @@ def tcontains_geo_tpoint(gs: 'const GSERIALIZED *', temp: 'const Temporal *', re gs_converted = _ffi.cast('const GSERIALIZED *', gs) temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tcontains_geo_tpoint(gs_converted, temp_converted, restr, atvalue) + _check_error() return result if result != _ffi.NULL else None @@ -5886,6 +6754,7 @@ def tdisjoint_tpoint_geo(temp: 'const Temporal *', geo: 'const GSERIALIZED *', r temp_converted = _ffi.cast('const Temporal *', temp) geo_converted = _ffi.cast('const GSERIALIZED *', geo) result = _lib.tdisjoint_tpoint_geo(temp_converted, geo_converted, restr, atvalue) + _check_error() return result if result != _ffi.NULL else None @@ -5893,6 +6762,7 @@ def tdwithin_tpoint_geo(temp: 'const Temporal *', gs: 'const GSERIALIZED *', dis temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.tdwithin_tpoint_geo(temp_converted, gs_converted, dist, restr, atvalue) + _check_error() return result if result != _ffi.NULL else None @@ -5900,6 +6770,7 @@ def tdwithin_tpoint_tpoint(temp1: 'const Temporal *', temp2: 'const Temporal *', temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.tdwithin_tpoint_tpoint(temp1_converted, temp2_converted, dist, restr, atvalue) + _check_error() return result if result != _ffi.NULL else None @@ -5907,6 +6778,7 @@ def tintersects_tpoint_geo(temp: 'const Temporal *', geo: 'const GSERIALIZED *', temp_converted = _ffi.cast('const Temporal *', temp) geo_converted = _ffi.cast('const GSERIALIZED *', geo) result = _lib.tintersects_tpoint_geo(temp_converted, geo_converted, restr, atvalue) + _check_error() return result if result != _ffi.NULL else None @@ -5914,6 +6786,7 @@ def ttouches_tpoint_geo(temp: 'const Temporal *', gs: 'const GSERIALIZED *', res temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) result = _lib.ttouches_tpoint_geo(temp_converted, gs_converted, restr, atvalue) + _check_error() return result if result != _ffi.NULL else None @@ -5921,6 +6794,7 @@ def tbool_tand_transfn(state: "Optional['SkipList *']", temp: 'const Temporal *' state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tbool_tand_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5928,6 +6802,7 @@ def tbool_tor_transfn(state: "Optional['SkipList *']", temp: 'const Temporal *') state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tbool_tor_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5935,12 +6810,14 @@ def temporal_extent_transfn(p: "Optional['Span *']", temp: 'const Temporal *') - p_converted = _ffi.cast('Span *', p) if p is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_extent_transfn(p_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_tagg_finalfn(state: 'SkipList *') -> 'Temporal *': state_converted = _ffi.cast('SkipList *', state) result = _lib.temporal_tagg_finalfn(state_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5948,6 +6825,7 @@ def temporal_tcount_transfn(state: "Optional['SkipList *']", temp: 'const Tempor state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_tcount_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5955,6 +6833,7 @@ def tfloat_tmax_transfn(state: "Optional['SkipList *']", temp: 'const Temporal * state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_tmax_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5962,6 +6841,7 @@ def tfloat_tmin_transfn(state: "Optional['SkipList *']", temp: 'const Temporal * state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_tmin_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5969,6 +6849,7 @@ def tfloat_tsum_transfn(state: "Optional['SkipList *']", temp: 'const Temporal * state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_tsum_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5976,6 +6857,7 @@ def tint_tmax_transfn(state: "Optional['SkipList *']", temp: 'const Temporal *') state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_tmax_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5983,6 +6865,7 @@ def tint_tmin_transfn(state: "Optional['SkipList *']", temp: 'const Temporal *') state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_tmin_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5990,6 +6873,7 @@ def tint_tsum_transfn(state: "Optional['SkipList *']", temp: 'const Temporal *') state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_tsum_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -5997,18 +6881,21 @@ def tnumber_extent_transfn(box: "Optional['TBox *']", temp: 'const Temporal *') box_converted = _ffi.cast('TBox *', box) if box is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tnumber_extent_transfn(box_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tnumber_integral(temp: 'const Temporal *') -> 'double': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tnumber_integral(temp_converted) + _check_error() return result if result != _ffi.NULL else None def tnumber_tavg_finalfn(state: 'SkipList *') -> 'Temporal *': state_converted = _ffi.cast('SkipList *', state) result = _lib.tnumber_tavg_finalfn(state_converted) + _check_error() return result if result != _ffi.NULL else None @@ -6016,12 +6903,14 @@ def tnumber_tavg_transfn(state: "Optional['SkipList *']", temp: 'const Temporal state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tnumber_tavg_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tnumber_twavg(temp: 'const Temporal *') -> 'double': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tnumber_twavg(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -6029,12 +6918,14 @@ def tpoint_extent_transfn(box: "Optional['STBox *']", temp: 'const Temporal *') box_converted = _ffi.cast('STBox *', box) if box is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_extent_transfn(box_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_tcentroid_finalfn(state: 'SkipList *') -> 'Temporal *': state_converted = _ffi.cast('SkipList *', state) result = _lib.tpoint_tcentroid_finalfn(state_converted) + _check_error() return result if result != _ffi.NULL else None @@ -6042,12 +6933,14 @@ def tpoint_tcentroid_transfn(state: 'SkipList *', temp: 'Temporal *') -> 'SkipLi state_converted = _ffi.cast('SkipList *', state) temp_converted = _ffi.cast('Temporal *', temp) result = _lib.tpoint_tcentroid_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def tpoint_twcentroid(temp: 'const Temporal *') -> 'GSERIALIZED *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tpoint_twcentroid(temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -6055,6 +6948,7 @@ def ttext_tmax_transfn(state: "Optional['SkipList *']", temp: 'const Temporal *' state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.ttext_tmax_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None @@ -6062,11 +6956,13 @@ def ttext_tmin_transfn(state: "Optional['SkipList *']", temp: 'const Temporal *' state_converted = _ffi.cast('SkipList *', state) if state is not None else _ffi.NULL temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.ttext_tmin_transfn(state_converted, temp_converted) + _check_error() return result if result != _ffi.NULL else None def float_bucket(value: float, size: float, origin: float) -> 'double': result = _lib.float_bucket(value, size, origin) + _check_error() return result if result != _ffi.NULL else None @@ -6074,11 +6970,13 @@ def floatspan_bucket_list(bounds: 'const Span *', size: float, origin: float, ne bounds_converted = _ffi.cast('const Span *', bounds) newcount_converted = _ffi.cast('int *', newcount) result = _lib.floatspan_bucket_list(bounds_converted, size, origin, newcount_converted) + _check_error() return result if result != _ffi.NULL else None def int_bucket(value: int, size: int, origin: int) -> 'int': result = _lib.int_bucket(value, size, origin) + _check_error() return result if result != _ffi.NULL else None @@ -6086,6 +6984,7 @@ def intspan_bucket_list(bounds: 'const Span *', size: int, origin: int, newcount bounds_converted = _ffi.cast('const Span *', bounds) newcount_converted = _ffi.cast('int *', newcount) result = _lib.intspan_bucket_list(bounds_converted, size, origin, newcount_converted) + _check_error() return result if result != _ffi.NULL else None @@ -6095,6 +6994,7 @@ def period_bucket_list(bounds: 'const Span *', duration: 'const Interval *', ori origin_converted = _ffi.cast('TimestampTz', origin) newcount_converted = _ffi.cast('int *', newcount) result = _lib.period_bucket_list(bounds_converted, duration_converted, origin_converted, newcount_converted) + _check_error() return result if result != _ffi.NULL else None @@ -6105,6 +7005,7 @@ def stbox_tile_list(bounds: 'const STBox *', xsize: float, ysize: float, zsize: torigin_converted = _ffi.cast('TimestampTz', torigin) cellcount = _ffi.new('int **') result = _lib.stbox_tile_list(bounds_converted, xsize, ysize, zsize, duration_converted, sorigin_converted, torigin_converted, cellcount) + _check_error() return result if result != _ffi.NULL else None, cellcount[0] @@ -6116,6 +7017,7 @@ def tbox_tile_list(bounds: 'const TBox *', xsize: float, duration: 'const Interv rows = _ffi.new('int *') columns = _ffi.new('int *') result = _lib.tbox_tile_list(bounds_converted, xsize, duration_converted, xorigin_converted, torigin_converted, rows, columns) + _check_error() return result if result != _ffi.NULL else None, rows[0], columns[0] @@ -6125,6 +7027,7 @@ def temporal_time_split(temp: 'Temporal *', duration: 'Interval *', torigin: int torigin_converted = _ffi.cast('TimestampTz', torigin) newcount = _ffi.new('int *') result = _lib.temporal_time_split(temp_converted, duration_converted, torigin_converted, newcount) + _check_error() return result if result != _ffi.NULL else None, newcount[0] @@ -6132,6 +7035,7 @@ def tfloat_value_split(temp: 'Temporal *', size: float, origin: float) -> "Tuple temp_converted = _ffi.cast('Temporal *', temp) newcount = _ffi.new('int *') result = _lib.tfloat_value_split(temp_converted, size, origin, newcount) + _check_error() return result if result != _ffi.NULL else None, newcount[0] @@ -6141,6 +7045,7 @@ def tfloat_value_time_split(temp: 'Temporal *', size: float, vorigin: float, dur torigin_converted = _ffi.cast('TimestampTz', torigin) newcount = _ffi.new('int *') result = _lib.tfloat_value_time_split(temp_converted, size, vorigin, duration_converted, torigin_converted, newcount) + _check_error() return result if result != _ffi.NULL else None, newcount[0] @@ -6149,6 +7054,7 @@ def timestamptz_bucket(timestamp: int, duration: 'const Interval *', origin: int duration_converted = _ffi.cast('const Interval *', duration) origin_converted = _ffi.cast('TimestampTz', origin) result = _lib.timestamptz_bucket(timestamp_converted, duration_converted, origin_converted) + _check_error() return result if result != _ffi.NULL else None @@ -6156,6 +7062,7 @@ def tint_value_split(temp: 'Temporal *', size: int, origin: int) -> "Tuple['Temp temp_converted = _ffi.cast('Temporal *', temp) newcount = _ffi.new('int *') result = _lib.tint_value_split(temp_converted, size, origin, newcount) + _check_error() return result if result != _ffi.NULL else None, newcount[0] @@ -6165,6 +7072,7 @@ def tint_value_time_split(temp: 'Temporal *', size: int, vorigin: int, duration: torigin_converted = _ffi.cast('TimestampTz', torigin) newcount = _ffi.new('int *') result = _lib.tint_value_time_split(temp_converted, size, vorigin, duration_converted, torigin_converted, newcount) + _check_error() return result if result != _ffi.NULL else None, newcount[0] @@ -6172,6 +7080,7 @@ def temporal_dyntimewarp_distance(temp1: 'const Temporal *', temp2: 'const Tempo temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_dyntimewarp_distance(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -6180,6 +7089,7 @@ def temporal_dyntimewarp_path(temp1: 'const Temporal *', temp2: 'const Temporal temp2_converted = _ffi.cast('const Temporal *', temp2) count = _ffi.new('int *') result = _lib.temporal_dyntimewarp_path(temp1_converted, temp2_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] @@ -6187,6 +7097,7 @@ def temporal_frechet_distance(temp1: 'const Temporal *', temp2: 'const Temporal temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_frechet_distance(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None @@ -6195,6 +7106,7 @@ def temporal_frechet_path(temp1: 'const Temporal *', temp2: 'const Temporal *') temp2_converted = _ffi.cast('const Temporal *', temp2) count = _ffi.new('int *') result = _lib.temporal_frechet_path(temp1_converted, temp2_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] @@ -6202,18 +7114,21 @@ def temporal_hausdorff_distance(temp1: 'const Temporal *', temp2: 'const Tempora temp1_converted = _ffi.cast('const Temporal *', temp1) temp2_converted = _ffi.cast('const Temporal *', temp2) result = _lib.temporal_hausdorff_distance(temp1_converted, temp2_converted) + _check_error() return result if result != _ffi.NULL else None def geo_to_tpoint(geo: 'const GSERIALIZED *') -> 'Temporal *': geo_converted = _ffi.cast('const GSERIALIZED *', geo) result = _lib.geo_to_tpoint(geo_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_simplify_min_dist(temp: 'const Temporal *', dist: float) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_simplify_min_dist(temp_converted, dist) + _check_error() return result if result != _ffi.NULL else None @@ -6221,18 +7136,21 @@ def temporal_simplify_min_tdelta(temp: 'const Temporal *', mint: 'const Interval temp_converted = _ffi.cast('const Temporal *', temp) mint_converted = _ffi.cast('const Interval *', mint) result = _lib.temporal_simplify_min_tdelta(temp_converted, mint_converted) + _check_error() return result if result != _ffi.NULL else None def temporal_simplify_dp(temp: 'const Temporal *', eps_dist: float, synchronized: bool) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_simplify_dp(temp_converted, eps_dist, synchronized) + _check_error() return result if result != _ffi.NULL else None def temporal_simplify_max_dist(temp: 'const Temporal *', eps_dist: float, synchronized: bool) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.temporal_simplify_max_dist(temp_converted, eps_dist, synchronized) + _check_error() return result if result != _ffi.NULL else None @@ -6245,6 +7163,7 @@ def tpoint_AsMVTGeom(temp: 'const Temporal *', bounds: 'const STBox *', extent: timesarr_converted = [_ffi.cast('int64 *', x) for x in timesarr] count = _ffi.new('int *') result = _lib.tpoint_AsMVTGeom(temp_converted, bounds_converted, extent_converted, buffer_converted, clip_geom, geom_converted, timesarr_converted, count) + _check_error() return result if result != _ffi.NULL else None, count[0] @@ -6253,6 +7172,7 @@ def tpoint_to_geo_meas(tpoint: 'const Temporal *', measure: 'const Temporal *', measure_converted = _ffi.cast('const Temporal *', measure) out_result = _ffi.new('GSERIALIZED **') result = _lib.tpoint_to_geo_meas(tpoint_converted, measure_converted, segmentize, out_result) + _check_error() if result: return out_result if out_result != _ffi.NULL else None return None From 513e0b96e12dfb5598869e049e7905cf8e6740c9 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Mon, 4 Sep 2023 16:57:41 +0200 Subject: [PATCH 4/6] Finish error setup --- pymeos_cffi/.gitignore | 4 +- pymeos_cffi/pymeos_cffi/__init__.py | 149 ++- .../pymeos_cffi/builder/build_header.py | 5 +- .../pymeos_cffi/builder/build_helpers.py | 713 ----------- .../builder/build_pymeos_functions.py | 163 +-- .../build_pymeos_functions_modifiers.py | 10 + pymeos_cffi/pymeos_cffi/builder/meos.h | 169 +-- .../builder/templates/functions.py | 124 ++ pymeos_cffi/pymeos_cffi/errors.py | 181 +++ pymeos_cffi/pymeos_cffi/functions.py | 1050 ++++++++++------- pymeos_cffi/test.py | 33 +- 11 files changed, 1208 insertions(+), 1393 deletions(-) delete mode 100644 pymeos_cffi/pymeos_cffi/builder/build_helpers.py create mode 100644 pymeos_cffi/pymeos_cffi/builder/templates/functions.py create mode 100644 pymeos_cffi/pymeos_cffi/errors.py diff --git a/pymeos_cffi/.gitignore b/pymeos_cffi/.gitignore index 3716b03c..f964f10d 100644 --- a/pymeos_cffi/.gitignore +++ b/pymeos_cffi/.gitignore @@ -7,4 +7,6 @@ dist *.c *.o -*.so \ No newline at end of file +*.so + +test.py \ No newline at end of file diff --git a/pymeos_cffi/pymeos_cffi/__init__.py b/pymeos_cffi/pymeos_cffi/__init__.py index c8ad0706..6db82fb3 100644 --- a/pymeos_cffi/pymeos_cffi/__init__.py +++ b/pymeos_cffi/pymeos_cffi/__init__.py @@ -1,6 +1,32 @@ from .functions import * +from .errors import * + __all__ = [ + # Exceptions + 'MeosException', + 'MeosInternalError', + 'MeosArgumentError', + 'MeosIoError', + 'MeosInternalTypeError', + 'MeosValueOutOfRangeError', + 'MeosDivisionByZeroError', + 'MeosMemoryAllocError', + 'MeosAggregationError', + 'MeosDirectoryError', + 'MeosFileError', + 'MeosInvalidArgError', + 'MeosInvalidArgTypeError', + 'MeosInvalidArgValueError', + 'MeosMfJsonInputError', + 'MeosMfJsonOutputError', + 'MeosTextInputError', + 'MeosTextOutputError', + 'MeosWkbInputError', + 'MeosWkbOutputError', + 'MeosGeoJsonInputError', + 'MeosGeoJsonOutputError', + # Functions 'create_pointer', 'get_address', 'datetime_to_timestamptz', @@ -17,7 +43,6 @@ 'as_tinstant', 'as_tsequence', 'as_tsequenceset', - 'meos_initialize', 'lwpoint_make', 'lwgeom_from_gserialized', 'gserialized_from_lwgeom', @@ -28,6 +53,7 @@ 'lwpoint_get_m', 'lwgeom_has_z', 'lwgeom_has_m', + 'meos_initialize', 'meos_finalize', 'bool_in', 'bool_out', @@ -55,6 +81,8 @@ 'pg_interval_to_char', 'pg_to_timestamp', 'pg_to_date', + 'geography_from_hexewkb', + 'geometry_from_hexewkb', 'gserialized_as_ewkb', 'gserialized_as_ewkt', 'gserialized_as_geojson', @@ -62,10 +90,11 @@ 'gserialized_as_text', 'gserialized_from_ewkb', 'gserialized_from_geojson', - 'gserialized_from_hexewkb', - 'gserialized_from_text', - 'gserialized_in', 'gserialized_out', + 'geometry_from_text', + 'geography_from_text', + 'pgis_geography_in', + 'pgis_geometry_in', 'pgis_gserialized_same', 'bigintset_in', 'bigintset_out', @@ -80,9 +109,8 @@ 'floatspanset_in', 'floatspanset_out', 'geogset_in', - 'geogset_out', + 'geoset_out', 'geomset_in', - 'geomset_out', 'geoset_as_ewkt', 'geoset_as_text', 'intset_in', @@ -118,8 +146,7 @@ 'bigintspan_make', 'floatset_make', 'floatspan_make', - 'geogset_make', - 'geomset_make', + 'geoset_make', 'intset_make', 'intspan_make', 'period_make', @@ -128,7 +155,6 @@ 'spanset_copy', 'spanset_make', 'spanset_make_exp', - 'spanset_make_free', 'textset_make', 'timestampset_make', 'bigint_to_bigintset', @@ -137,11 +163,13 @@ 'float_to_floatset', 'float_to_floatspan', 'float_to_floatspanset', + 'geo_to_geoset', 'int_to_intset', 'int_to_intspan', 'int_to_intspanset', 'set_to_spanset', 'span_to_spanset', + 'text_to_textset', 'timestamp_to_period', 'timestamp_to_periodset', 'timestamp_to_tstzset', @@ -161,7 +189,11 @@ 'floatspan_upper', 'floatspanset_lower', 'floatspanset_upper', + 'geoset_end_value', 'geoset_srid', + 'geoset_start_value', + 'geoset_value_n', + 'geoset_values', 'intset_end_value', 'intset_start_value', 'intset_value_n', @@ -204,6 +236,10 @@ 'spanset_upper_inc', 'spanset_width', 'spatialset_stbox', + 'textset_end_value', + 'textset_start_value', + 'textset_value_n', + 'textset_values', 'timestampset_end_timestamp', 'timestampset_start_timestamp', 'timestampset_timestamp_n', @@ -211,15 +247,11 @@ 'floatset_round', 'floatspan_round', 'floatspanset_round', - 'floatspan_set_intspan', 'geoset_round', - 'intspan_set_floatspan', 'period_tprecision', 'periodset_tprecision', 'period_shift_tscale', 'periodset_shift_tscale', - 'set_shift', - 'span_expand', 'timestamp_tprecision', 'timestampset_shift_tscale', 'adjacent_bigintspan_bigint', @@ -322,30 +354,69 @@ 'right_span_spanset', 'right_spanset_span', 'right_spanset_spanset', - 'bbox_union_span_span', - 'intersection_set_set', + 'intersection_bigintset_bigint', + 'intersection_bigintspan_bigint', + 'intersection_bigintspanset_bigint', + 'intersection_floatset_float', + 'intersection_floatspan_float', + 'intersection_floatspanset_float', + 'intersection_intset_int', + 'intersection_intspan_int', + 'intersection_intspanset_int', 'intersection_period_timestamp', 'intersection_periodset_timestamp', + 'intersection_set_set', 'intersection_span_span', 'intersection_spanset_span', 'intersection_spanset_spanset', + 'intersection_textset_text', 'intersection_timestampset_timestamp', - 'minus_set_set', + 'minus_bigint_bigintset', + 'minus_bigint_bigintspan', + 'minus_bigint_bigintspanset', + 'minus_bigintset_bigint', + 'minus_bigintspan_bigint', + 'minus_bigintspanset_bigint', + 'minus_float_floatset', + 'minus_float_floatspan', + 'minus_float_floatspanset', + 'minus_floatset_float', + 'minus_floatspan_float', + 'minus_floatspanset_float', + 'minus_int_intset', + 'minus_int_intspan', + 'minus_int_intspanset', + 'minus_intset_int', + 'minus_intspan_int', + 'minus_intspanset_int', 'minus_period_timestamp', 'minus_periodset_timestamp', + 'minus_set_set', 'minus_span_span', 'minus_span_spanset', 'minus_spanset_span', 'minus_spanset_spanset', + 'minus_text_textset', + 'minus_textset_text', 'minus_timestamp_period', 'minus_timestamp_periodset', 'minus_timestampset_timestamp', - 'union_set_set', + 'union_bigintset_bigint', + 'union_bigintspan_bigint', + 'union_bigintspanset_bigint', + 'union_floatset_float', + 'union_floatspan_float', + 'union_floatspanset_float', + 'union_intset_int', + 'union_intspan_int', + 'union_intspanset_int', 'union_period_timestamp', 'union_periodset_timestamp', + 'union_set_set', 'union_span_span', 'union_spanset_span', 'union_spanset_spanset', + 'union_textset_text', 'union_timestampset_timestamp', 'distance_floatspan_float', 'distance_intspan_int', @@ -410,12 +481,10 @@ 'stbox_as_hexwkb', 'stbox_in', 'stbox_out', - 'tbox_make', - 'tbox_set', - 'tbox_copy', 'stbox_make', - 'stbox_set', 'stbox_copy', + 'tbox_make', + 'tbox_copy', 'int_to_tbox', 'float_to_tbox', 'timestamp_to_tbox', @@ -467,13 +536,11 @@ 'stbox_tmax', 'stbox_tmax_inc', 'stbox_srid', - 'stbox_expand', 'stbox_expand_space', 'stbox_expand_time', 'stbox_get_space', 'stbox_round', 'stbox_set_srid', - 'tbox_expand', 'tbox_expand_value', 'tbox_expand_time', 'tbox_round', @@ -562,21 +629,16 @@ 'tfloatseq_from_base_period', 'tfloatseq_from_base_timestampset', 'tfloatseqset_from_base_periodset', - 'tgeogpoint_from_base_temp', - 'tgeogpointinst_make', - 'tgeogpointseq_from_base_period', - 'tgeogpointseq_from_base_timestampset', - 'tgeogpointseqset_from_base_periodset', - 'tgeompoint_from_base_temp', - 'tgeompointinst_make', - 'tgeompointseq_from_base_period', - 'tgeompointseq_from_base_timestampset', - 'tgeompointseqset_from_base_periodset', 'tint_from_base_temp', 'tintinst_make', 'tintseq_from_base_period', 'tintseq_from_base_timestampset', 'tintseqset_from_base_periodset', + 'tpoint_from_base_temp', + 'tpointinst_make', + 'tpointseq_from_base_period', + 'tpointseq_from_base_timestampset', + 'tpointseqset_from_base_periodset', 'tsequence_make', 'tsequence_make_exp', 'tsequenceset_make', @@ -618,7 +680,6 @@ 'temporal_time', 'temporal_timestamp_n', 'temporal_timestamps', - 'temporal_values', 'tfloat_end_value', 'tfloat_max_value', 'tfloat_min_value', @@ -765,10 +826,6 @@ 'tfloat_ever_eq', 'tfloat_ever_le', 'tfloat_ever_lt', - 'tgeogpoint_always_eq', - 'tgeogpoint_ever_eq', - 'tgeompoint_always_eq', - 'tgeompoint_ever_eq', 'tint_always_eq', 'tint_always_le', 'tint_always_lt', @@ -792,18 +849,14 @@ 'temporal_ne', 'teq_bool_tbool', 'teq_float_tfloat', - 'teq_geo_tpoint', 'teq_int_tint', - 'teq_point_tgeogpoint', - 'teq_point_tgeompoint', + 'teq_point_tpoint', 'teq_tbool_bool', 'teq_temporal_temporal', 'teq_text_ttext', 'teq_tfloat_float', - 'teq_tgeogpoint_point', - 'teq_tgeompoint_point', + 'teq_tpoint_point', 'teq_tint_int', - 'teq_tpoint_geo', 'teq_ttext_text', 'tge_float_tfloat', 'tge_int_tint', @@ -835,18 +888,14 @@ 'tlt_ttext_text', 'tne_bool_tbool', 'tne_float_tfloat', - 'tne_geo_tpoint', 'tne_int_tint', - 'tne_point_tgeogpoint', - 'tne_point_tgeompoint', + 'tne_point_tpoint', 'tne_tbool_bool', 'tne_temporal_temporal', 'tne_text_ttext', 'tne_tfloat_float', - 'tne_tgeogpoint_point', - 'tne_tgeompoint_point', + 'tne_tpoint_point', 'tne_tint_int', - 'tne_tpoint_geo', 'tne_ttext_text', 'bearing_point_point', 'bearing_tpoint_point', diff --git a/pymeos_cffi/pymeos_cffi/builder/build_header.py b/pymeos_cffi/pymeos_cffi/builder/build_header.py index 06043ae3..38e3e1a0 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_header.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_header.py @@ -42,7 +42,8 @@ def main(header_path, so_path=None): if so_path: content = remove_undefined_functions(content, so_path) - content += '\n\nextern "Python" void py_error_handler(int, char*);' + # Add error handler + content += '\n\nextern "Python" void py_error_handler(int, int, char*);' with open('pymeos_cffi/builder/meos.h', 'w') as f: f.write(content) @@ -50,8 +51,6 @@ def main(header_path, so_path=None): if __name__ == '__main__': if len(sys.argv) > 1: - get_defined_functions(sys.argv[2]) main(sys.argv[1], sys.argv[2]) else: - get_defined_functions('/usr/local/lib/libmeos.so') main('/usr/local/include/meos.h', '/usr/local/lib/libmeos.so') diff --git a/pymeos_cffi/pymeos_cffi/builder/build_helpers.py b/pymeos_cffi/pymeos_cffi/builder/build_helpers.py deleted file mode 100644 index 60674ea2..00000000 --- a/pymeos_cffi/pymeos_cffi/builder/build_helpers.py +++ /dev/null @@ -1,713 +0,0 @@ -LIBLWGEOM_DEFINITIONS = """ -typedef uint16_t lwflags_t; - -/******************************************************************/ - -typedef struct { - double afac, bfac, cfac, dfac, efac, ffac, gfac, hfac, ifac, xoff, yoff, zoff; -} AFFINE; - -/******************************************************************/ - -typedef struct -{ - double xmin, ymin, zmin; - double xmax, ymax, zmax; - int32_t srid; -} -BOX3D; - -/****************************************************************** -* GBOX structure. -* We include the flags (information about dimensionality), -* so we don't have to constantly pass them -* into functions that use the GBOX. -*/ -typedef struct -{ - lwflags_t flags; - double xmin; - double xmax; - double ymin; - double ymax; - double zmin; - double zmax; - double mmin; - double mmax; -} GBOX; - - -/****************************************************************** -* SPHEROID -* -* Standard definition of an ellipsoid (what wkt calls a spheroid) -* f = (a-b)/a -* e_sq = (a*a - b*b)/(a*a) -* b = a - fa -*/ -typedef struct -{ - double a; /* semimajor axis */ - double b; /* semiminor axis b = (a - fa) */ - double f; /* flattening f = (a-b)/a */ - double e; /* eccentricity (first) */ - double e_sq; /* eccentricity squared (first) e_sq = (a*a-b*b)/(a*a) */ - double radius; /* spherical average radius = (2*a+b)/3 */ - char name[20]; /* name of ellipse */ -} -SPHEROID; - -/****************************************************************** -* POINT2D, POINT3D, POINT3DM, POINT4D -*/ -typedef struct -{ - double x, y; -} -POINT2D; - -typedef struct -{ - double x, y, z; -} -POINT3DZ; - -typedef struct -{ - double x, y, z; -} -POINT3D; - -typedef struct -{ - double x, y, m; -} -POINT3DM; - -typedef struct -{ - double x, y, z, m; -} -POINT4D; - -/****************************************************************** -* POINTARRAY -* Point array abstracts a lot of the complexity of points and point lists. -* It handles 2d/3d translation -* (2d points converted to 3d will have z=0 or NaN) -* DO NOT MIX 2D and 3D POINTS! EVERYTHING* is either one or the other -*/ -typedef struct -{ - uint32_t npoints; /* how many points we are currently storing */ - uint32_t maxpoints; /* how many points we have space for in serialized_pointlist */ - - /* Use FLAGS_* macros to handle */ - lwflags_t flags; - - /* Array of POINT 2D, 3D or 4D, possibly misaligned. */ - uint8_t *serialized_pointlist; -} -POINTARRAY; - -/****************************************************************** -* GSERIALIZED -*/ - -typedef struct -{ - uint32_t size; /* For PgSQL use only, use VAR* macros to manipulate. */ - uint8_t srid[3]; /* 24 bits of SRID */ - uint8_t gflags; /* HasZ, HasM, HasBBox, IsGeodetic */ - uint8_t data[1]; /* See gserialized.txt */ -} GSERIALIZED; - -/****************************************************************** -* LWGEOM (any geometry type) -* -* Abstract type, note that 'type', 'bbox' and 'srid' are available in -* all geometry variants. -*/ -typedef struct -{ - GBOX *bbox; - void *data; - int32_t srid; - lwflags_t flags; - uint8_t type; - char pad[1]; /* Padding to 24 bytes (unused) */ -} -LWGEOM; - -/* POINTYPE */ -typedef struct -{ - GBOX *bbox; - POINTARRAY *point; /* hide 2d/3d (this will be an array of 1 point) */ - int32_t srid; - lwflags_t flags; - uint8_t type; /* POINTTYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ -} -LWPOINT; /* "light-weight point" */ - -/* LINETYPE */ -typedef struct -{ - GBOX *bbox; - POINTARRAY *points; /* array of POINT3D */ - int32_t srid; - lwflags_t flags; - uint8_t type; /* LINETYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ -} -LWLINE; /* "light-weight line" */ - -/* TRIANGLE */ -typedef struct -{ - GBOX *bbox; - POINTARRAY *points; - int32_t srid; - lwflags_t flags; - uint8_t type; - char pad[1]; /* Padding to 24 bytes (unused) */ -} -LWTRIANGLE; - -/* CIRCSTRINGTYPE */ -typedef struct -{ - GBOX *bbox; - POINTARRAY *points; /* array of POINT(3D/3DM) */ - int32_t srid; - lwflags_t flags; - uint8_t type; /* CIRCSTRINGTYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ -} -LWCIRCSTRING; /* "light-weight circularstring" */ - -/* POLYGONTYPE */ -typedef struct -{ - GBOX *bbox; - POINTARRAY **rings; /* list of rings (list of points) */ - int32_t srid; - lwflags_t flags; - uint8_t type; /* POLYGONTYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ - uint32_t nrings; /* how many rings we are currently storing */ - uint32_t maxrings; /* how many rings we have space for in **rings */ -} -LWPOLY; /* "light-weight polygon" */ - -/* MULTIPOINTTYPE */ -typedef struct -{ - GBOX *bbox; - LWPOINT **geoms; - int32_t srid; - lwflags_t flags; - uint8_t type; /* MULTYPOINTTYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ -} -LWMPOINT; - -/* MULTILINETYPE */ -typedef struct -{ - GBOX *bbox; - LWLINE **geoms; - int32_t srid; - lwflags_t flags; - uint8_t type; /* MULTILINETYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ -} -LWMLINE; - -/* MULTIPOLYGONTYPE */ -typedef struct -{ - GBOX *bbox; - LWPOLY **geoms; - int32_t srid; - lwflags_t flags; - uint8_t type; /* MULTIPOLYGONTYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ -} -LWMPOLY; - -/* COLLECTIONTYPE */ -typedef struct -{ - GBOX *bbox; - LWGEOM **geoms; - int32_t srid; - lwflags_t flags; - uint8_t type; /* COLLECTIONTYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ -} -LWCOLLECTION; - -/* COMPOUNDTYPE */ -typedef struct -{ - GBOX *bbox; - LWGEOM **geoms; - int32_t srid; - lwflags_t flags; - uint8_t type; /* COLLECTIONTYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ -} -LWCOMPOUND; /* "light-weight compound line" */ - -/* CURVEPOLYTYPE */ -typedef struct -{ - GBOX *bbox; - LWGEOM **rings; - int32_t srid; - lwflags_t flags; - uint8_t type; /* CURVEPOLYTYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ - uint32_t nrings; /* how many rings we are currently storing */ - uint32_t maxrings; /* how many rings we have space for in **rings */ -} -LWCURVEPOLY; /* "light-weight polygon" */ - -/* MULTICURVE */ -typedef struct -{ - GBOX *bbox; - LWGEOM **geoms; - int32_t srid; - lwflags_t flags; - uint8_t type; /* MULTICURVE */ - char pad[1]; /* Padding to 24 bytes (unused) */ - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ -} -LWMCURVE; - -/* MULTISURFACETYPE */ -typedef struct -{ - GBOX *bbox; - LWGEOM **geoms; - int32_t srid; - lwflags_t flags; - uint8_t type; /* MULTISURFACETYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ -} -LWMSURFACE; - -/* POLYHEDRALSURFACETYPE */ -typedef struct -{ - GBOX *bbox; - LWPOLY **geoms; - int32_t srid; - lwflags_t flags; - uint8_t type; /* POLYHEDRALSURFACETYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ -} -LWPSURFACE; - -/* TINTYPE */ -typedef struct -{ - GBOX *bbox; - LWTRIANGLE **geoms; - int32_t srid; - lwflags_t flags; - uint8_t type; /* TINTYPE */ - char pad[1]; /* Padding to 24 bytes (unused) */ - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ -} -LWTIN; - -extern LWPOINT *lwpoint_make(int32_t srid, int hasz, int hasm, const POINT4D *p); - -extern LWGEOM *lwgeom_from_gserialized(const GSERIALIZED *g); -extern GSERIALIZED *gserialized_from_lwgeom(LWGEOM *geom, size_t *size); - -extern int32_t lwgeom_get_srid(const LWGEOM *geom); - -extern double lwpoint_get_x(const LWPOINT *point); -extern double lwpoint_get_y(const LWPOINT *point); -extern double lwpoint_get_z(const LWPOINT *point); -extern double lwpoint_get_m(const LWPOINT *point); - -extern int lwgeom_has_z(const LWGEOM *geom); -extern int lwgeom_has_m(const LWGEOM *geom); -""" - -LIBLWGEOM_DEFINITIONS_2 = """ - -typedef struct { - double afac, bfac, cfac, dfac, efac, ffac, gfac, hfac, ifac, xoff, yoff, zoff; -} AFFINE; - -/******************************************************************/ - -typedef struct -{ - double xmin, ymin, zmin; - double xmax, ymax, zmax; - int32_t srid; -} -BOX3D; - -/****************************************************************** -* GBOX structure. -* We include the flags (information about dimensionality), -* so we don't have to constantly pass them -* into functions that use the GBOX. -*/ -typedef struct -{ - uint8_t flags; - double xmin; - double xmax; - double ymin; - double ymax; - double zmin; - double zmax; - double mmin; - double mmax; -} GBOX; - - -/****************************************************************** -* SPHEROID -* -* Standard definition of an ellipsoid (what wkt calls a spheroid) -* f = (a-b)/a -* e_sq = (a*a - b*b)/(a*a) -* b = a - fa -*/ -typedef struct -{ - double a; /* semimajor axis */ - double b; /* semiminor axis b = (a - fa) */ - double f; /* flattening f = (a-b)/a */ - double e; /* eccentricity (first) */ - double e_sq; /* eccentricity squared (first) e_sq = (a*a-b*b)/(a*a) */ - double radius; /* spherical average radius = (2*a+b)/3 */ - char name[20]; /* name of ellipse */ -} -SPHEROID; - -/****************************************************************** -* POINT2D, POINT3D, POINT3DM, POINT4D -*/ -typedef struct -{ - double x, y; -} -POINT2D; - -typedef struct -{ - double x, y, z; -} -POINT3DZ; - -typedef struct -{ - double x, y, z; -} -POINT3D; - -typedef struct -{ - double x, y, m; -} -POINT3DM; - -typedef struct -{ - double x, y, z, m; -} -POINT4D; - -/****************************************************************** -* POINTARRAY -* Point array abstracts a lot of the complexity of points and point lists. -* It handles 2d/3d translation -* (2d points converted to 3d will have z=0 or NaN) -* DO NOT MIX 2D and 3D POINTS! EVERYTHING* is either one or the other -*/ -typedef struct -{ - /* Array of POINT 2D, 3D or 4D, possibly misaligned. */ - uint8_t *serialized_pointlist; - - /* Use FLAGS_* macros to handle */ - uint8_t flags; - - uint32_t npoints; /* how many points we are currently storing */ - uint32_t maxpoints; /* how many points we have space for in serialized_pointlist */ -} -POINTARRAY; - -/****************************************************************** -* GSERIALIZED -*/ -typedef struct -{ - uint32_t size; /* For PgSQL use only, use VAR* macros to manipulate. */ - uint8_t srid[3]; /* 24 bits of SRID */ - uint8_t flags; /* HasZ, HasM, HasBBox, IsGeodetic, IsReadOnly */ - uint8_t data[1]; /* See gserialized.txt */ -} GSERIALIZED; - - -/****************************************************************** -* LWGEOM (any geometry type) -* -* Abstract type, note that 'type', 'bbox' and 'srid' are available in -* all geometry variants. -*/ -typedef struct -{ - uint8_t type; - uint8_t flags; - GBOX *bbox; - int32_t srid; - void *data; -} -LWGEOM; - -/* POINTYPE */ -typedef struct -{ - uint8_t type; /* POINTTYPE */ - uint8_t flags; - GBOX *bbox; - int32_t srid; - POINTARRAY *point; /* hide 2d/3d (this will be an array of 1 point) */ -} -LWPOINT; /* "light-weight point" */ - -/* LINETYPE */ -typedef struct -{ - uint8_t type; /* LINETYPE */ - uint8_t flags; - GBOX *bbox; - int32_t srid; - POINTARRAY *points; /* array of POINT3D */ -} -LWLINE; /* "light-weight line" */ - -/* TRIANGLE */ -typedef struct -{ - uint8_t type; - uint8_t flags; - GBOX *bbox; - int32_t srid; - POINTARRAY *points; -} -LWTRIANGLE; - -/* CIRCSTRINGTYPE */ -typedef struct -{ - uint8_t type; /* CIRCSTRINGTYPE */ - uint8_t flags; - GBOX *bbox; - int32_t srid; - POINTARRAY *points; /* array of POINT(3D/3DM) */ -} -LWCIRCSTRING; /* "light-weight circularstring" */ - -/* POLYGONTYPE */ -typedef struct -{ - uint8_t type; /* POLYGONTYPE */ - uint8_t flags; - GBOX *bbox; - int32_t srid; - uint32_t nrings; /* how many rings we are currently storing */ - uint32_t maxrings; /* how many rings we have space for in **rings */ - POINTARRAY **rings; /* list of rings (list of points) */ -} -LWPOLY; /* "light-weight polygon" */ - -/* MULTIPOINTTYPE */ -typedef struct -{ - uint8_t type; - uint8_t flags; - GBOX *bbox; - int32_t srid; - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ - LWPOINT **geoms; -} -LWMPOINT; - -/* MULTILINETYPE */ -typedef struct -{ - uint8_t type; - uint8_t flags; - GBOX *bbox; - int32_t srid; - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ - LWLINE **geoms; -} -LWMLINE; - -/* MULTIPOLYGONTYPE */ -typedef struct -{ - uint8_t type; - uint8_t flags; - GBOX *bbox; - int32_t srid; - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ - LWPOLY **geoms; -} -LWMPOLY; - -/* COLLECTIONTYPE */ -typedef struct -{ - uint8_t type; - uint8_t flags; - GBOX *bbox; - int32_t srid; - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ - LWGEOM **geoms; -} -LWCOLLECTION; - -/* COMPOUNDTYPE */ -typedef struct -{ - uint8_t type; /* COMPOUNDTYPE */ - uint8_t flags; - GBOX *bbox; - int32_t srid; - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ - LWGEOM **geoms; -} -LWCOMPOUND; /* "light-weight compound line" */ - -/* CURVEPOLYTYPE */ -typedef struct -{ - uint8_t type; /* CURVEPOLYTYPE */ - uint8_t flags; - GBOX *bbox; - int32_t srid; - uint32_t nrings; /* how many rings we are currently storing */ - uint32_t maxrings; /* how many rings we have space for in **rings */ - LWGEOM **rings; /* list of rings (list of points) */ -} -LWCURVEPOLY; /* "light-weight polygon" */ - -/* MULTICURVE */ -typedef struct -{ - uint8_t type; - uint8_t flags; - GBOX *bbox; - int32_t srid; - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ - LWGEOM **geoms; -} -LWMCURVE; - -/* MULTISURFACETYPE */ -typedef struct -{ - uint8_t type; - uint8_t flags; - GBOX *bbox; - int32_t srid; - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ - LWGEOM **geoms; -} -LWMSURFACE; - -/* POLYHEDRALSURFACETYPE */ -typedef struct -{ - uint8_t type; - uint8_t flags; - GBOX *bbox; - int32_t srid; - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ - LWPOLY **geoms; -} -LWPSURFACE; - -/* TINTYPE */ -typedef struct -{ - uint8_t type; - uint8_t flags; - GBOX *bbox; - int32_t srid; - uint32_t ngeoms; /* how many geometries we are currently storing */ - uint32_t maxgeoms; /* how many geometries we have space for in **geoms */ - LWTRIANGLE **geoms; -} -LWTIN; - - -extern LWPOINT *lwpoint_make(int32_t srid, int hasz, int hasm, const POINT4D *p); - -extern LWGEOM *lwgeom_from_gserialized(const GSERIALIZED *g); -extern GSERIALIZED *gserialized_from_lwgeom(LWGEOM *geom, size_t *size); - -extern static inline LWPOINT *lwgeom_as_lwpoint(const LWGEOM *lwgeom); - -extern int32_t lwgeom_get_srid(const LWGEOM *geom); - -extern double lwpoint_get_x(const LWPOINT *point); -extern double lwpoint_get_y(const LWPOINT *point); -extern double lwpoint_get_z(const LWPOINT *point); -extern double lwpoint_get_m(const LWPOINT *point); - -extern int lwgeom_has_z(const LWGEOM *geom); -extern int lwgeom_has_m(const LWGEOM *geom); -""" - -ADDITIONAL_DEFINITIONS = ( - """/***************************************************************************** - * Type definitions - *****************************************************************************/""" - , - """ -""" + LIBLWGEOM_DEFINITIONS + """ -/***************************************************************************** - * Type definitions - *****************************************************************************/""" -) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py index 8367b864..848f2c2b 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py @@ -38,140 +38,22 @@ def __init__(self, ctype: str, ptype: str, conversion: Optional[str]) -> None: self.conversion = conversion -BASE = """from datetime import datetime, timedelta -from typing import Any, Tuple, Optional, List, Union - -import _meos_cffi -import postgis as pg -import shapely.geometry as spg -from dateutil.parser import parse -from shapely import wkt, wkb, get_srid -from shapely.geometry.base import BaseGeometry -from spans.types import floatrange, intrange - -_ffi = _meos_cffi.ffi -_lib = _meos_cffi.lib - -_error = None - - -def _check_error() -> None: - global _error - if _error is not None: - error_copy = _error - _error = None - raise Exception(error_copy) - - -@_ffi.def_extern() -def py_error_handler(error_code, error_msg): - global _error - _error = _ffi.string(error_msg).decode('utf-8') - - -def create_pointer(object: 'Any', type: str) -> 'Any *': - return _ffi.new(f'{type} *', object) - - -def get_address(value: 'Any') -> 'Any *': - return _ffi.addressof(value) - - -def datetime_to_timestamptz(dt: datetime) -> int: - return _lib.pg_timestamptz_in(dt.strftime('%Y-%m-%d %H:%M:%S%z').encode('utf-8'), -1) - - -def timestamptz_to_datetime(ts: int) -> datetime: - return parse(pg_timestamptz_out(ts)) - - -def timedelta_to_interval(td: timedelta) -> Any: - return _ffi.new('Interval *', {'time': td.microseconds + td.seconds * 1000000, 'day': td.days, 'month': 0}) - - -def interval_to_timedelta(interval: Any) -> timedelta: - # TODO fix for months/years - return timedelta(days=interval.day, microseconds=interval.time) - - -def geometry_to_gserialized(geom: Union[pg.Geometry, BaseGeometry], geodetic: Optional[bool] = None) -> 'GSERIALIZED *': - if isinstance(geom, pg.Geometry): - text = geom.to_ewkb() - # if geom.has_srid(): - # text = f'SRID={geom.srid};{text}' - elif isinstance(geom, BaseGeometry): - text = wkb.dumps(geom, hex=True) - if get_srid(geom) > 0: - text = f'SRID={get_srid(geom)};{text}' - else: - raise TypeError('Parameter geom must be either a PostGIS Geometry or a Shapely BaseGeometry') - gs = gserialized_in(text, -1) - if geodetic is not None: - # GFlags is an 8-bit integer, where the 4th bit is the geodetic flag (0x80) - # If geodetic is True, then set the 4th bit to 1, otherwise set it to 0 - gs.gflags = (gs.gflags | 0x08) if geodetic else (gs.gflags & 0xF7) - return gs - - -def gserialized_to_shapely_point(geom: 'const GSERIALIZED *', precision: int = 6) -> spg.Point: - return wkt.loads(gserialized_as_text(geom, precision)) - - -def gserialized_to_shapely_geometry(geom: 'const GSERIALIZED *', precision: int = 6) -> BaseGeometry: - return wkt.loads(gserialized_as_text(geom, precision)) - - -def intrange_to_intspan(irange: intrange) -> 'Span *': - return intspan_make(irange.lower, irange.upper, irange.lower_inc, irange.upper_inc) - - -def intspan_to_intrange(ispan: 'Span *') -> intrange: - return intrange(intspan_lower(ispan), intspan_upper(ispan), ispan.lower_inc, ispan.upper_inc) - - -def floatrange_to_floatspan(frange: floatrange) -> 'Span *': - return floatspan_make(frange.lower, frange.upper, frange.lower_inc, frange.upper_inc) - - -def floatspan_to_floatrange(fspan: 'Span *') -> floatrange: - return floatrange(floatspan_lower(fspan), floatspan_upper(fspan), fspan.lower_inc, fspan.upper_inc) - - -def as_tinstant(temporal: 'Temporal *') -> 'TInstant *': - return _ffi.cast('TInstant *', temporal) - - -def as_tsequence(temporal: 'Temporal *') -> 'TSequence *': - return _ffi.cast('TSequence *', temporal) - - -def as_tsequenceset(temporal: 'Temporal *') -> 'TSequenceSet *': - return _ffi.cast('TSequenceSet *', temporal) - - -# ----------------------------------------------------------------------------- -# ----------------------End of manually-defined functions---------------------- -# ----------------------------------------------------------------------------- - -def meos_initialize(tz_str: "Optional[str]") -> None: - tz_str_converted = tz_str.encode('utf-8') if tz_str is not None else _ffi.NULL - _lib.meos_initialize(tz_str_converted, _lib.py_error_handler) - - - -""" - # List of functions defined in functions.py that shouldn't be exported hidden_functions = [ '_check_error', - 'py_error_handler' + 'py_error_handler', + 'meos_initialize_timezone', + 'meos_initialize_error_handler', + 'meos_finalize_timezone', ] function_notes = { } function_modifiers = { + 'meos_initialize': meos_initialize_modifier, + 'meos_finalize': remove_error_check_modifier, 'cstring2text': cstring2text_modifier, 'text2cstring': text2cstring_modifier, 'timestampset_make': timestampset_make_modifier, @@ -325,8 +207,11 @@ def main(): r'\((?P[\w\s,\*]*)\);' matches = re.finditer(f_regex, ''.join(content.splitlines()), flags=RegexFlag.MULTILINE) + with open('pymeos_cffi/builder/templates/functions.py') as f: + base = f.read() + with open('pymeos_cffi/functions.py', 'w+') as file: - file.write(BASE) + file.write(base) for match in matches: named = match.groupdict() function = named['function'] @@ -344,7 +229,33 @@ def main(): content = funcs.read() f_names = re.finditer(r'def (\w+)\(', content) init.write('from .functions import *\n\n') - init.write('__all__ = [\n') + init.write('from .errors import *\n\n') + init.write('__all__ = [\n' + " # Exceptions \n" + " 'MeosException',\n" + " 'MeosInternalError',\n" + " 'MeosArgumentError',\n" + " 'MeosIoError',\n" + " 'MeosInternalTypeError',\n" + " 'MeosValueOutOfRangeError',\n" + " 'MeosDivisionByZeroError',\n" + " 'MeosMemoryAllocError',\n" + " 'MeosAggregationError',\n" + " 'MeosDirectoryError',\n" + " 'MeosFileError',\n" + " 'MeosInvalidArgError',\n" + " 'MeosInvalidArgTypeError',\n" + " 'MeosInvalidArgValueError',\n" + " 'MeosMfJsonInputError',\n" + " 'MeosMfJsonOutputError',\n" + " 'MeosTextInputError',\n" + " 'MeosTextOutputError',\n" + " 'MeosWkbInputError',\n" + " 'MeosWkbOutputError',\n" + " 'MeosGeoJsonInputError',\n" + " 'MeosGeoJsonOutputError',\n" + " # Functions\n" + ) for fn in f_names: function_name = fn.group(1) if function_name in hidden_functions: diff --git a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions_modifiers.py b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions_modifiers.py index 91fe41eb..aa361106 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions_modifiers.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions_modifiers.py @@ -7,6 +7,16 @@ def array_length_remover_modifier(list_name: str, length_param_name: str = 'coun .replace(f', {length_param_name}', f', len({list_name})') +def meos_initialize_modifier(_: str) -> str: + return """def meos_initialize(tz_str: "Optional[str]") -> None: + tz_str_converted = tz_str.encode('utf-8') if tz_str is not None else _ffi.NULL + _lib.meos_initialize(tz_str_converted, _lib.py_error_handler)""" + + +def remove_error_check_modifier(function: str) -> str: + return function.replace(' _check_error()\n', '') + + def cstring2text_modifier(_: str) -> str: return """def cstring2text(cstring: str) -> 'text *': cstring_converted = cstring.encode('utf-8') diff --git a/pymeos_cffi/pymeos_cffi/builder/meos.h b/pymeos_cffi/pymeos_cffi/builder/meos.h index 65cd1ba7..f63cdcb3 100644 --- a/pymeos_cffi/pymeos_cffi/builder/meos.h +++ b/pymeos_cffi/pymeos_cffi/builder/meos.h @@ -482,8 +482,6 @@ extern LWPOINT *lwpoint_make(int32_t srid, int hasz, int hasm, const POINT4D *p) extern LWGEOM *lwgeom_from_gserialized(const GSERIALIZED *g); extern GSERIALIZED *gserialized_from_lwgeom(LWGEOM *geom, size_t *size); - - extern int32_t lwgeom_get_srid(const LWGEOM *geom); extern double lwpoint_get_x(const LWPOINT *point); @@ -735,7 +733,14 @@ typedef struct * Initialization of the MEOS library *****************************************************************************/ -extern void meos_initialize(const char *tz_str, void (*handler_p)(int, char*)); + +typedef void (*error_handler_fn)(int, int, char *); + +extern void meos_initialize_timezone(const char *name); +extern void meos_initialize_error_handler(error_handler_fn err_handler); +extern void meos_finalize_timezone(void); + +extern void meos_initialize(const char *tz_str, error_handler_fn err_handler); extern void meos_finalize(void); /***************************************************************************** @@ -773,18 +778,21 @@ extern DateADT pg_to_date(text *date_txt, text *fmt); * Functions for input/output and manipulation of PostGIS types *****************************************************************************/ -extern bytea *gserialized_as_ewkb(const GSERIALIZED *geom, char *type); -extern char *gserialized_as_ewkt(const GSERIALIZED *geom, int precision); -extern char *gserialized_as_geojson(const GSERIALIZED *geom, int option, int precision, char *srs); -extern char *gserialized_as_hexewkb(const GSERIALIZED *geom, const char *type); -extern char *gserialized_as_text(const GSERIALIZED *geom, int precision); +extern GSERIALIZED *geography_from_hexewkb(const char *wkt); +extern GSERIALIZED *geometry_from_hexewkb(const char *wkt); +extern bytea *gserialized_as_ewkb(const GSERIALIZED *gs, char *type); +extern char *gserialized_as_ewkt(const GSERIALIZED *gs, int precision); +extern char *gserialized_as_geojson(const GSERIALIZED *gs, int option, int precision, char *srs); +extern char *gserialized_as_hexewkb(const GSERIALIZED *gs, const char *type); +extern char *gserialized_as_text(const GSERIALIZED *gs, int precision); extern GSERIALIZED *gserialized_from_ewkb(const bytea *bytea_wkb, int32 srid); extern GSERIALIZED *gserialized_from_geojson(const char *geojson); -extern GSERIALIZED *gserialized_from_hexewkb(const char *wkt); -extern GSERIALIZED *gserialized_from_text(char *wkt, int srid); -extern GSERIALIZED *gserialized_in(char *input, int32 geom_typmod); -extern char *gserialized_out(const GSERIALIZED *geom); -extern bool pgis_gserialized_same(const GSERIALIZED *geom1, const GSERIALIZED *geom2); +extern char *gserialized_out(const GSERIALIZED *gs); +extern GSERIALIZED *geometry_from_text(char *wkt, int srid); +extern GSERIALIZED *geography_from_text(char *wkt, int srid); +extern GSERIALIZED *pgis_geography_in(char *input, int32 geom_typmod); +extern GSERIALIZED *pgis_geometry_in(char *input, int32 geom_typmod); +extern bool pgis_gserialized_same(const GSERIALIZED *gs1, const GSERIALIZED *geom2); /***************************************************************************** * Functions for set and span types @@ -805,9 +813,8 @@ extern char *floatspan_out(const Span *s, int maxdd); extern SpanSet *floatspanset_in(const char *str); extern char *floatspanset_out(const SpanSet *ss, int maxdd); extern Set *geogset_in(const char *str); -extern char *geogset_out(const Set *set, int maxdd); +extern char *geoset_out(const Set *set, int maxdd); extern Set *geomset_in(const char *str); -extern char *geomset_out(const Set *set, int maxdd); extern char *geoset_as_ewkt(const Set *set, int maxdd); extern char *geoset_as_text(const Set *set, int maxdd); extern Set *intset_in(const char *str); @@ -848,8 +855,7 @@ extern Set *bigintset_make(const int64 *values, int count); extern Span *bigintspan_make(int64 lower, int64 upper, bool lower_inc, bool upper_inc); extern Set *floatset_make(const double *values, int count); extern Span *floatspan_make(double lower, double upper, bool lower_inc, bool upper_inc); -extern Set *geogset_make(const GSERIALIZED **values, int count); -extern Set *geomset_make(const GSERIALIZED **values, int count); +extern Set *geoset_make(const GSERIALIZED **values, int count); extern Set *intset_make(const int *values, int count); extern Span *intspan_make(int lower, int upper, bool lower_inc, bool upper_inc); extern Span *period_make(TimestampTz lower, TimestampTz upper, bool lower_inc, bool upper_inc); @@ -858,7 +864,6 @@ extern Span *span_copy(const Span *s); extern SpanSet *spanset_copy(const SpanSet *ps); extern SpanSet *spanset_make(Span *spans, int count, bool normalize); extern SpanSet *spanset_make_exp(Span *spans, int count, int maxcount, bool normalize, bool ordered); -extern SpanSet *spanset_make_free(Span *spans, int count, bool normalize); extern Set *textset_make(const text **values, int count); extern Set *timestampset_make(const TimestampTz *values, int count); @@ -872,11 +877,13 @@ extern SpanSet *bigint_to_bigintspanset(int i); extern Set *float_to_floatset(double d); extern Span *float_to_floatspan(double d); extern SpanSet *float_to_floatspanset(double d); +extern Set *geo_to_geoset(GSERIALIZED *gs); extern Set *int_to_intset(int i); extern Span *int_to_intspan(int i); extern SpanSet *int_to_intspanset(int i); extern SpanSet *set_to_spanset(const Set *s); extern SpanSet *span_to_spanset(const Span *s); +extern Set *text_to_textset(text *txt); extern Span *timestamp_to_period(TimestampTz t); extern SpanSet *timestamp_to_periodset(TimestampTz t); extern Set *timestamp_to_tstzset(TimestampTz t); @@ -901,7 +908,11 @@ extern double floatspan_lower(const Span *s); extern double floatspan_upper(const Span *s); extern double floatspanset_lower(const SpanSet *ss); extern double floatspanset_upper(const SpanSet *ss); +extern GSERIALIZED *geoset_end_value(const Set *s); extern int geoset_srid(const Set *set); +extern GSERIALIZED *geoset_start_value(const Set *s); +extern bool geoset_value_n(const Set *s, int n, GSERIALIZED **result); +extern GSERIALIZED **geoset_values(const Set *s); extern int intset_end_value(const Set *s); extern int intset_start_value(const Set *s); extern bool intset_value_n(const Set *s, int n, int *result); @@ -944,6 +955,10 @@ extern Span *spanset_start_span(const SpanSet *ss); extern bool spanset_upper_inc(const SpanSet *ss); extern double spanset_width(const SpanSet *ss); extern STBox *spatialset_stbox(const Set *s); +extern text *textset_end_value(const Set *s); +extern text *textset_start_value(const Set *s); +extern bool textset_value_n(const Set *s, int n, text **result); +extern text **textset_values(const Set *s); extern TimestampTz timestampset_end_timestamp(const Set *ts); extern TimestampTz timestampset_start_timestamp(const Set *ts); extern bool timestampset_timestamp_n(const Set *ts, int n, TimestampTz *result); @@ -956,15 +971,11 @@ extern TimestampTz *timestampset_values(const Set *ts); extern Set *floatset_round(const Set *s, int maxdd); extern Span *floatspan_round(const Span *s, int maxdd); extern SpanSet *floatspanset_round(const SpanSet *ss, int maxdd); -extern void floatspan_set_intspan(const Span *s1, Span *s2); extern Set *geoset_round(const Set *s, int maxdd); -extern void intspan_set_floatspan(const Span *s1, Span *s2); extern Span *period_tprecision(const Span *s, const Interval *duration, TimestampTz torigin); extern SpanSet *periodset_tprecision(const SpanSet *ss, const Interval *duration, TimestampTz torigin); extern Span *period_shift_tscale(const Span *p, const Interval *shift, const Interval *duration); extern SpanSet *periodset_shift_tscale(const SpanSet *ps, const Interval *shift, const Interval *duration); -extern Set *set_shift(const Set *s, Datum shift); -extern void span_expand(const Span *s1, Span *s2); extern TimestampTz timestamp_tprecision(TimestampTz t, const Interval *duration, TimestampTz torigin); extern Set *timestampset_shift_tscale(const Set *ts, const Interval *shift, const Interval *duration); @@ -1084,31 +1095,70 @@ extern bool right_spanset_spanset(const SpanSet *ss1, const SpanSet *ss2); -extern void bbox_union_span_span(const Span *s1, const Span *s2, Span *result); +extern bool intersection_bigintset_bigint(const Set *s, int64 i, int64 *result); +extern bool intersection_bigintspan_bigint(const Span *s, int64 i, int64 *result); +extern bool intersection_bigintspanset_bigint(const SpanSet *ss, int64 i, int64 *result); +extern bool intersection_floatset_float(const Set *s, double d, double *result); +extern bool intersection_floatspan_float(const Span *s, double d, double *result); +extern bool intersection_floatspanset_float(const SpanSet *ss, double d, double *result); +extern bool intersection_intset_int(const Set *s, int i, int *result); +extern bool intersection_intspan_int(const Span *s, int i, int *result); +extern bool intersection_intspanset_int(const SpanSet *ss, int i, int *result); +extern bool intersection_period_timestamp(const Span *s, TimestampTz t, TimestampTz *result); +extern bool intersection_periodset_timestamp(const SpanSet *ss, TimestampTz t, TimestampTz *result); extern Set *intersection_set_set(const Set *s1, const Set *s2); -extern bool intersection_period_timestamp(const Span *p, TimestampTz t, TimestampTz *result); -extern bool intersection_periodset_timestamp(const SpanSet *ps, TimestampTz t, TimestampTz *result); extern Span *intersection_span_span(const Span *s1, const Span *s2); extern SpanSet *intersection_spanset_span(const SpanSet *ss, const Span *s); extern SpanSet *intersection_spanset_spanset(const SpanSet *ss1, const SpanSet *ss2); -extern bool intersection_timestampset_timestamp(const Set *ts, const TimestampTz t, TimestampTz *result); +extern bool intersection_textset_text(const Set *s, const text *txt, text **result); +extern bool intersection_timestampset_timestamp(const Set *s, TimestampTz t, TimestampTz *result); +extern bool minus_bigint_bigintset(int64 i, const Set *s, int64 *result); +extern bool minus_bigint_bigintspan(int64 i, const Span *s, int64 *result); +extern bool minus_bigint_bigintspanset(int64 i, const SpanSet *ss, int64 *result); +extern Set *minus_bigintset_bigint(const Set *s, int64 i); +extern SpanSet *minus_bigintspan_bigint(const Span *s, int64 i); +extern SpanSet *minus_bigintspanset_bigint(const SpanSet *ss, int64 i); +extern bool minus_float_floatset(double d, const Set *s, double *result); +extern bool minus_float_floatspan(double d, const Span *s, double *result); +extern bool minus_float_floatspanset(double d, const SpanSet *ss, double *result); +extern Set *minus_floatset_float(const Set *s, double d); +extern SpanSet *minus_floatspan_float(const Span *s, double d); +extern SpanSet *minus_floatspanset_float(const SpanSet *ss, double d); +extern bool minus_int_intset(int i, const Set *s, int *result); +extern bool minus_int_intspan(int i, const Span *s, int *result); +extern bool minus_int_intspanset(int i, const SpanSet *ss, int *result); +extern Set *minus_intset_int(const Set *s, int i); +extern SpanSet *minus_intspan_int(const Span *s, int i); +extern SpanSet *minus_intspanset_int(const SpanSet *ss, int i); +extern SpanSet *minus_period_timestamp(const Span *s, TimestampTz t); +extern SpanSet *minus_periodset_timestamp(const SpanSet *ss, TimestampTz t); extern Set *minus_set_set(const Set *s1, const Set *s2); -extern SpanSet *minus_period_timestamp(const Span *p, TimestampTz t); -extern SpanSet *minus_periodset_timestamp(const SpanSet *ps, TimestampTz t); extern SpanSet *minus_span_span(const Span *s1, const Span *s2); extern SpanSet *minus_span_spanset(const Span *s, const SpanSet *ss); extern SpanSet *minus_spanset_span(const SpanSet *ss, const Span *s); extern SpanSet *minus_spanset_spanset(const SpanSet *ss1, const SpanSet *ss2); -extern bool minus_timestamp_period(TimestampTz t, const Span *p, TimestampTz *result); -extern bool minus_timestamp_periodset(TimestampTz t, const SpanSet *ps, TimestampTz *result); -extern Set *minus_timestampset_timestamp(const Set *ts, TimestampTz t); +extern bool minus_text_textset(const text *txt, const Set *s, text **result); +extern Set *minus_textset_text(const Set *s, const text *txt); +extern bool minus_timestamp_period(TimestampTz t, const Span *s, TimestampTz *result); +extern bool minus_timestamp_periodset(TimestampTz t, const SpanSet *ss, TimestampTz *result); +extern Set *minus_timestampset_timestamp(const Set *s, TimestampTz t); +extern Set *union_bigintset_bigint(const Set *s, int64 i); +extern SpanSet *union_bigintspan_bigint(const Span *s, int64 i); +extern SpanSet *union_bigintspanset_bigint(const SpanSet *ss, int64 i); +extern Set *union_floatset_float(const Set *s, double d); +extern SpanSet *union_floatspan_float(const Span *s, double d); +extern SpanSet *union_floatspanset_float(const SpanSet *ss, double d); +extern Set *union_intset_int(const Set *s, int i); +extern SpanSet *union_intspan_int(const Span *s, int i); +extern SpanSet *union_intspanset_int(const SpanSet *ss, int i); +extern SpanSet *union_period_timestamp(const Span *s, TimestampTz t); +extern SpanSet *union_periodset_timestamp(SpanSet *ss, TimestampTz t); extern Set *union_set_set(const Set *s1, const Set *s2); -extern SpanSet *union_period_timestamp(const Span *p, TimestampTz t); -extern SpanSet *union_periodset_timestamp(SpanSet *ps, TimestampTz t); extern SpanSet *union_span_span(const Span *s1, const Span *s2); extern SpanSet *union_spanset_span(const SpanSet *ss, const Span *s); extern SpanSet *union_spanset_spanset(const SpanSet *ss1, const SpanSet *ss2); -extern Set *union_timestampset_timestamp(const Set *ts, const TimestampTz t); +extern Set *union_textset_text(const Set *s, text *txt); +extern Set *union_timestampset_timestamp(const Set *s, const TimestampTz t); @@ -1199,14 +1249,11 @@ extern char *stbox_out(const STBox *box, int maxdd); -extern TBox *tbox_make(const Span *s, const Span *p); -extern void tbox_set(const Span *s, const Span *p, TBox *box); -extern TBox *tbox_copy(const TBox *box); extern STBox * stbox_make(bool hasx, bool hasz, bool geodetic, int32 srid, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, const Span *p); -extern void stbox_set(bool hasx, bool hasz, bool geodetic, int32 srid, double xmin, double xmax, - double ymin, double ymax, double zmin, double zmax, const Span *p, STBox *box); extern STBox *stbox_copy(const STBox *box); +extern TBox *tbox_make(const Span *s, const Span *p); +extern TBox *tbox_copy(const TBox *box); @@ -1273,13 +1320,11 @@ extern int32 stbox_srid(const STBox *box); -extern void stbox_expand(const STBox *box1, STBox *box2); extern STBox *stbox_expand_space(const STBox *box, double d); extern STBox *stbox_expand_time(const STBox *box, const Interval *interval); extern STBox *stbox_get_space(const STBox *box); extern STBox *stbox_round(const STBox *box, int maxdd); extern STBox *stbox_set_srid(const STBox *box, int32 srid); -extern void tbox_expand(const TBox *box1, TBox *box2); extern TBox *tbox_expand_value(const TBox *box, const double d); extern TBox *tbox_expand_time(const TBox *box, const Interval *interval); extern TBox *tbox_round(const TBox *box, int maxdd); @@ -1405,21 +1450,16 @@ extern TInstant *tfloatinst_make(double d, TimestampTz t); extern TSequence *tfloatseq_from_base_period(double d, const Span *p, interpType interp); extern TSequence *tfloatseq_from_base_timestampset(double d, const Set *ts); extern TSequenceSet *tfloatseqset_from_base_periodset(double d, const SpanSet *ps, interpType interp); -extern Temporal *tgeogpoint_from_base_temp(const GSERIALIZED *gs, const Temporal *temp); -extern TInstant *tgeogpointinst_make(const GSERIALIZED *gs, TimestampTz t); -extern TSequence *tgeogpointseq_from_base_period(const GSERIALIZED *gs, const Span *p, interpType interp); -extern TSequence *tgeogpointseq_from_base_timestampset(const GSERIALIZED *gs, const Set *ts); -extern TSequenceSet *tgeogpointseqset_from_base_periodset(const GSERIALIZED *gs, const SpanSet *ps, interpType interp); -extern Temporal *tgeompoint_from_base_temp(const GSERIALIZED *gs, const Temporal *temp); -extern TInstant *tgeompointinst_make(const GSERIALIZED *gs, TimestampTz t); -extern TSequence *tgeompointseq_from_base_period(const GSERIALIZED *gs, const Span *p, interpType interp); -extern TSequence *tgeompointseq_from_base_timestampset(const GSERIALIZED *gs, const Set *ts); -extern TSequenceSet *tgeompointseqset_from_base_periodset(const GSERIALIZED *gs, const SpanSet *ps, interpType interp); extern Temporal *tint_from_base_temp(int i, const Temporal *temp); extern TInstant *tintinst_make(int i, TimestampTz t); extern TSequence *tintseq_from_base_period(int i, const Span *p); extern TSequence *tintseq_from_base_timestampset(int i, const Set *ts); extern TSequenceSet *tintseqset_from_base_periodset(int i, const SpanSet *ps); +extern Temporal *tpoint_from_base_temp(const GSERIALIZED *gs, const Temporal *temp); +extern TInstant *tpointinst_make(const GSERIALIZED *gs, TimestampTz t); +extern TSequence *tpointseq_from_base_period(const GSERIALIZED *gs, const Span *p, interpType interp); +extern TSequence *tpointseq_from_base_timestampset(const GSERIALIZED *gs, const Set *ts); +extern TSequenceSet *tpointseqset_from_base_periodset(const GSERIALIZED *gs, const SpanSet *ps, interpType interp); extern TSequence *tsequence_make(const TInstant **instants, int count, bool lower_inc, bool upper_inc, interpType interp, bool normalize); extern TSequence *tsequence_make_exp(const TInstant **instants, int count, int maxcount, bool lower_inc, bool upper_inc, interpType interp, bool normalize); extern TSequenceSet *tsequenceset_make(const TSequence **sequences, int count, bool normalize); @@ -1471,7 +1511,6 @@ extern char *temporal_subtype(const Temporal *temp); extern SpanSet *temporal_time(const Temporal *temp); extern bool temporal_timestamp_n(const Temporal *temp, int n, TimestampTz *result); extern TimestampTz *temporal_timestamps(const Temporal *temp, int *count); -extern Datum *temporal_values(const Temporal *temp, int *count); extern double tfloat_end_value(const Temporal *temp); extern double tfloat_max_value(const Temporal *temp); extern double tfloat_min_value(const Temporal *temp); @@ -1658,18 +1697,14 @@ extern bool tfloat_always_lt(const Temporal *temp, double d); extern bool tfloat_ever_eq(const Temporal *temp, double d); extern bool tfloat_ever_le(const Temporal *temp, double d); extern bool tfloat_ever_lt(const Temporal *temp, double d); -extern bool tgeogpoint_always_eq(const Temporal *temp, GSERIALIZED *gs);; -extern bool tgeogpoint_ever_eq(const Temporal *temp, GSERIALIZED *gs);; -extern bool tgeompoint_always_eq(const Temporal *temp, GSERIALIZED *gs); -extern bool tgeompoint_ever_eq(const Temporal *temp, GSERIALIZED *gs);; extern bool tint_always_eq(const Temporal *temp, int i); extern bool tint_always_le(const Temporal *temp, int i); extern bool tint_always_lt(const Temporal *temp, int i); extern bool tint_ever_eq(const Temporal *temp, int i); extern bool tint_ever_le(const Temporal *temp, int i); extern bool tint_ever_lt(const Temporal *temp, int i); -extern bool tpoint_always_eq(const Temporal *temp, Datum value); -extern bool tpoint_ever_eq(const Temporal *temp, Datum value); +extern bool tpoint_always_eq(const Temporal *temp, const GSERIALIZED *gs);; +extern bool tpoint_ever_eq(const Temporal *temp, const GSERIALIZED *gs);; extern bool ttext_always_eq(const Temporal *temp, text *txt); extern bool ttext_always_le(const Temporal *temp, text *txt); extern bool ttext_always_lt(const Temporal *temp, text *txt); @@ -1690,18 +1725,14 @@ extern bool temporal_lt(const Temporal *temp1, const Temporal *temp2); extern bool temporal_ne(const Temporal *temp1, const Temporal *temp2); extern Temporal *teq_bool_tbool(bool b, const Temporal *temp); extern Temporal *teq_float_tfloat(double d, const Temporal *temp); -extern Temporal *teq_geo_tpoint(const GSERIALIZED *geo, const Temporal *tpoint); extern Temporal *teq_int_tint(int i, const Temporal *temp); -extern Temporal *teq_point_tgeogpoint(const GSERIALIZED *gs, const Temporal *temp); -extern Temporal *teq_point_tgeompoint(const GSERIALIZED *gs, const Temporal *temp); +extern Temporal *teq_point_tpoint(const GSERIALIZED *gs, const Temporal *temp); extern Temporal *teq_tbool_bool(const Temporal *temp, bool b); extern Temporal *teq_temporal_temporal(const Temporal *temp1, const Temporal *temp2); extern Temporal *teq_text_ttext(const text *txt, const Temporal *temp); extern Temporal *teq_tfloat_float(const Temporal *temp, double d); -extern Temporal *teq_tgeogpoint_point(const Temporal *temp, const GSERIALIZED *gs); -extern Temporal *teq_tgeompoint_point(const Temporal *temp, const GSERIALIZED *gs); +extern Temporal *teq_tpoint_point(const Temporal *temp, const GSERIALIZED *gs); extern Temporal *teq_tint_int(const Temporal *temp, int i); -extern Temporal *teq_tpoint_geo(const Temporal *tpoint, const GSERIALIZED *geo); extern Temporal *teq_ttext_text(const Temporal *temp, const text *txt); extern Temporal *tge_float_tfloat(double d, const Temporal *temp); extern Temporal *tge_int_tint(int i, const Temporal *temp); @@ -1733,18 +1764,14 @@ extern Temporal *tlt_tint_int(const Temporal *temp, int i); extern Temporal *tlt_ttext_text(const Temporal *temp, const text *txt); extern Temporal *tne_bool_tbool(bool b, const Temporal *temp); extern Temporal *tne_float_tfloat(double d, const Temporal *temp); -extern Temporal *tne_geo_tpoint(const GSERIALIZED *geo, const Temporal *tpoint); extern Temporal *tne_int_tint(int i, const Temporal *temp); -extern Temporal *tne_point_tgeogpoint(const GSERIALIZED *gs, const Temporal *temp); -extern Temporal *tne_point_tgeompoint(const GSERIALIZED *gs, const Temporal *temp); +extern Temporal *tne_point_tpoint(const GSERIALIZED *gs, const Temporal *temp); extern Temporal *tne_tbool_bool(const Temporal *temp, bool b); extern Temporal *tne_temporal_temporal(const Temporal *temp1, const Temporal *temp2); extern Temporal *tne_text_ttext(const text *txt, const Temporal *temp); extern Temporal *tne_tfloat_float(const Temporal *temp, double d); -extern Temporal *tne_tgeogpoint_point(const Temporal *temp, const GSERIALIZED *gs); -extern Temporal *tne_tgeompoint_point(const Temporal *temp, const GSERIALIZED *gs); +extern Temporal *tne_tpoint_point(const Temporal *temp, const GSERIALIZED *gs); extern Temporal *tne_tint_int(const Temporal *temp, int i); -extern Temporal *tne_tpoint_geo(const Temporal *tpoint, const GSERIALIZED *geo); extern Temporal *tne_ttext_text(const Temporal *temp, const text *txt); /***************************************************************************** @@ -1871,4 +1898,4 @@ bool tpoint_to_geo_meas(const Temporal *tpoint, const Temporal *measure, bool se //#endif -extern "Python" void py_error_handler(int, char*); \ No newline at end of file +extern "Python" void py_error_handler(int, int, char*); \ No newline at end of file diff --git a/pymeos_cffi/pymeos_cffi/builder/templates/functions.py b/pymeos_cffi/pymeos_cffi/builder/templates/functions.py new file mode 100644 index 00000000..f91e622f --- /dev/null +++ b/pymeos_cffi/pymeos_cffi/builder/templates/functions.py @@ -0,0 +1,124 @@ +from datetime import datetime, timedelta +from typing import Any, Tuple, Optional, List, Union + +import _meos_cffi +from .errors import raise_meos_exception +import postgis as pg +import shapely.geometry as spg +from dateutil.parser import parse +from shapely import wkt, wkb, get_srid +from shapely.geometry.base import BaseGeometry +from spans.types import floatrange, intrange + +_ffi = _meos_cffi.ffi +_lib = _meos_cffi.lib + +_error: Optional[int] = None +_error_level: Optional[int] = None +_error_message: Optional[str] = None + + +def _check_error() -> None: + global _error, _error_level, _error_message + if _error is not None: + error = _error + error_level = _error_level + error_message = _error_message + _error = None + _error_level = None + _error_message = None + raise_meos_exception(error_level, error, error_message) + + +@_ffi.def_extern() +def py_error_handler(error_level, error_code, error_msg): + global _error, _error_level, _error_message + _error = error_code + _error_level = error_level + _error_message = _ffi.string(error_msg).decode('utf-8') + + +def create_pointer(object: 'Any', type: str) -> 'Any *': + return _ffi.new(f'{type} *', object) + + +def get_address(value: 'Any') -> 'Any *': + return _ffi.addressof(value) + + +def datetime_to_timestamptz(dt: datetime) -> int: + return _lib.pg_timestamptz_in(dt.strftime('%Y-%m-%d %H:%M:%S%z').encode('utf-8'), -1) + + +def timestamptz_to_datetime(ts: int) -> datetime: + return parse(pg_timestamptz_out(ts)) + + +def timedelta_to_interval(td: timedelta) -> Any: + return _ffi.new('Interval *', {'time': td.microseconds + td.seconds * 1000000, 'day': td.days, 'month': 0}) + + +def interval_to_timedelta(interval: Any) -> timedelta: + # TODO fix for months/years + return timedelta(days=interval.day, microseconds=interval.time) + + +def geometry_to_gserialized(geom: Union[pg.Geometry, BaseGeometry], geodetic: Optional[bool] = None) -> 'GSERIALIZED *': + if isinstance(geom, pg.Geometry): + text = geom.to_ewkb() + # if geom.has_srid(): + # text = f'SRID={geom.srid};{text}' + elif isinstance(geom, BaseGeometry): + text = wkb.dumps(geom, hex=True) + if get_srid(geom) > 0: + text = f'SRID={get_srid(geom)};{text}' + else: + raise TypeError('Parameter geom must be either a PostGIS Geometry or a Shapely BaseGeometry') + gs = gserialized_in(text, -1) + if geodetic is not None: + # GFlags is an 8-bit integer, where the 4th bit is the geodetic flag (0x80) + # If geodetic is True, then set the 4th bit to 1, otherwise set it to 0 + gs.gflags = (gs.gflags | 0x08) if geodetic else (gs.gflags & 0xF7) + return gs + + +def gserialized_to_shapely_point(geom: 'const GSERIALIZED *', precision: int = 6) -> spg.Point: + return wkt.loads(gserialized_as_text(geom, precision)) + + +def gserialized_to_shapely_geometry(geom: 'const GSERIALIZED *', precision: int = 6) -> BaseGeometry: + return wkt.loads(gserialized_as_text(geom, precision)) + + +def intrange_to_intspan(irange: intrange) -> 'Span *': + return intspan_make(irange.lower, irange.upper, irange.lower_inc, irange.upper_inc) + + +def intspan_to_intrange(ispan: 'Span *') -> intrange: + return intrange(intspan_lower(ispan), intspan_upper(ispan), ispan.lower_inc, ispan.upper_inc) + + +def floatrange_to_floatspan(frange: floatrange) -> 'Span *': + return floatspan_make(frange.lower, frange.upper, frange.lower_inc, frange.upper_inc) + + +def floatspan_to_floatrange(fspan: 'Span *') -> floatrange: + return floatrange(floatspan_lower(fspan), floatspan_upper(fspan), fspan.lower_inc, fspan.upper_inc) + + +def as_tinstant(temporal: 'Temporal *') -> 'TInstant *': + return _ffi.cast('TInstant *', temporal) + + +def as_tsequence(temporal: 'Temporal *') -> 'TSequence *': + return _ffi.cast('TSequence *', temporal) + + +def as_tsequenceset(temporal: 'Temporal *') -> 'TSequenceSet *': + return _ffi.cast('TSequenceSet *', temporal) + + +# ----------------------------------------------------------------------------- +# ----------------------End of manually-defined functions---------------------- +# ----------------------------------------------------------------------------- + diff --git a/pymeos_cffi/pymeos_cffi/errors.py b/pymeos_cffi/pymeos_cffi/errors.py new file mode 100644 index 00000000..e186e682 --- /dev/null +++ b/pymeos_cffi/pymeos_cffi/errors.py @@ -0,0 +1,181 @@ +from enum import IntEnum + + +class MEOSCode(IntEnum): + MEOS_SUCCESS = 0, # Successful operation + + MEOS_ERR_INTERNAL_ERROR = 1, # Unspecified internal error + MEOS_ERR_INTERNAL_TYPE_ERROR = 2, # Internal type error + MEOS_ERR_VALUE_OUT_OF_RANGE = 3, # Internal out of range error + MEOS_ERR_DIVISION_BY_ZERO = 4, # Internal division by zero error + MEOS_ERR_MEMORY_ALLOC_ERROR = 5, # Internal malloc error + MEOS_ERR_AGGREGATION_ERROR = 6, # Internal aggregation error + MEOS_ERR_DIRECTORY_ERROR = 7, # Internal directory error + MEOS_ERR_FILE_ERROR = 8, # Internal file error + + MEOS_ERR_INVALID_ARG = 10, # Invalid argument + MEOS_ERR_INVALID_ARG_TYPE = 11, # Invalid argument type + MEOS_ERR_INVALID_ARG_VALUE = 12, # Invalid argument value + + MEOS_ERR_MFJSON_INPUT = 20, # MFJSON input error + MEOS_ERR_MFJSON_OUTPUT = 21, # MFJSON output error + MEOS_ERR_TEXT_INPUT = 22, # Text input error + MEOS_ERR_TEXT_OUTPUT = 23, # Text output error + MEOS_ERR_WKB_INPUT = 24, # WKB input error + MEOS_ERR_WKB_OUTPUT = 25, # WKB output error + MEOS_ERR_GEOJSON_INPUT = 26, # GEOJSON input error + MEOS_ERR_GEOJSON_OUTPUT = 27, # GEOJSON output error + + +class MeosException(Exception): + """Base class for all MEOS errors.""" + + def __init__(self, code: int, message: str): + super().__init__(message) + self.code = code + + +class MeosInternalError(MeosException): + """Superclass for internal errors.""" + pass + + +class MeosArgumentError(MeosException): + """Superclass for invalid argument errors.""" + pass + + +class MeosIoError(MeosException): + """Unspecified internal error.""" + pass + + +class MeosInternalTypeError(MeosInternalError): + """Internal type error.""" + pass + + +class MeosValueOutOfRangeError(MeosInternalError): + """Internal out of range error.""" + pass + + +class MeosDivisionByZeroError(MeosInternalError): + """Internal division by zero error.""" + pass + + +class MeosMemoryAllocError(MeosInternalError): + """Internal malloc error.""" + pass + + +class MeosAggregationError(MeosInternalError): + """Internal aggregation error.""" + pass + + +class MeosDirectoryError(MeosInternalError): + """Internal directory error.""" + pass + + +class MeosFileError(MeosInternalError): + """Internal file error.""" + pass + + +class MeosInvalidArgError(MeosArgumentError): + """Invalid argument.""" + pass + + +class MeosInvalidArgTypeError(MeosArgumentError): + """Invalid argument type.""" + pass + + +class MeosInvalidArgValueError(MeosArgumentError): + """Invalid argument value.""" + pass + + +class MeosMfJsonInputError(MeosIoError): + """MFJSON input error.""" + pass + + +class MeosMfJsonOutputError(MeosIoError): + """MFJSON output error.""" + pass + + +class MeosTextInputError(MeosIoError): + """Text input error.""" + pass + + +class MeosTextOutputError(MeosIoError): + """Text output error.""" + pass + + +class MeosWkbInputError(MeosIoError): + """WKB input error.""" + pass + + +class MeosWkbOutputError(MeosIoError): + """WKB output error.""" + pass + + +class MeosGeoJsonInputError(MeosIoError): + """GEOJSON input error.""" + pass + + +class MeosGeoJsonOutputError(MeosIoError): + """GEOJSON output error.""" + pass + + +def raise_meos_exception(level: int, code: int, message: str): + if code == MEOSCode.MEOS_ERR_INTERNAL_ERROR: + raise MeosInternalError(code, message) + elif code == MEOSCode.MEOS_ERR_INTERNAL_TYPE_ERROR: + raise MeosInternalTypeError(code, message) + elif code == MEOSCode.MEOS_ERR_VALUE_OUT_OF_RANGE: + raise MeosValueOutOfRangeError(code, message) + elif code == MEOSCode.MEOS_ERR_DIVISION_BY_ZERO: + raise MeosDivisionByZeroError(code, message) + elif code == MEOSCode.MEOS_ERR_MEMORY_ALLOC_ERROR: + raise MeosMemoryAllocError(code, message) + elif code == MEOSCode.MEOS_ERR_AGGREGATION_ERROR: + raise MeosAggregationError(code, message) + elif code == MEOSCode.MEOS_ERR_DIRECTORY_ERROR: + raise MeosDirectoryError(code, message) + elif code == MEOSCode.MEOS_ERR_FILE_ERROR: + raise MeosFileError(code, message) + elif code == MEOSCode.MEOS_ERR_INVALID_ARG: + raise MeosInvalidArgError(code, message) + elif code == MEOSCode.MEOS_ERR_INVALID_ARG_TYPE: + raise MeosInvalidArgTypeError(code, message) + elif code == MEOSCode.MEOS_ERR_INVALID_ARG_VALUE: + raise MeosInvalidArgValueError(code, message) + elif code == MEOSCode.MEOS_ERR_MFJSON_INPUT: + raise MeosMfJsonInputError(code, message) + elif code == MEOSCode.MEOS_ERR_MFJSON_OUTPUT: + raise MeosMfJsonOutputError(code, message) + elif code == MEOSCode.MEOS_ERR_TEXT_INPUT: + raise MeosTextInputError(code, message) + elif code == MEOSCode.MEOS_ERR_TEXT_OUTPUT: + raise MeosTextOutputError(code, message) + elif code == MEOSCode.MEOS_ERR_WKB_INPUT: + raise MeosWkbInputError(code, message) + elif code == MEOSCode.MEOS_ERR_WKB_OUTPUT: + raise MeosWkbOutputError(code, message) + elif code == MEOSCode.MEOS_ERR_GEOJSON_INPUT: + raise MeosGeoJsonInputError(code, message) + elif code == MEOSCode.MEOS_ERR_GEOJSON_OUTPUT: + raise MeosGeoJsonOutputError(code, message) diff --git a/pymeos_cffi/pymeos_cffi/functions.py b/pymeos_cffi/pymeos_cffi/functions.py index b78a3279..e02f8f1d 100644 --- a/pymeos_cffi/pymeos_cffi/functions.py +++ b/pymeos_cffi/pymeos_cffi/functions.py @@ -2,6 +2,7 @@ from typing import Any, Tuple, Optional, List, Union import _meos_cffi +from .errors import raise_meos_exception import postgis as pg import shapely.geometry as spg from dateutil.parser import parse @@ -12,26 +13,34 @@ _ffi = _meos_cffi.ffi _lib = _meos_cffi.lib -_error = None +_error: Optional[int] = None +_error_level: Optional[int] = None +_error_message: Optional[str] = None def _check_error() -> None: - global _error + global _error, _error_level, _error_message if _error is not None: - error_copy = _error + error = _error + error_level = _error_level + error_message = _error_message _error = None - raise Exception(error_copy) + _error_level = None + _error_message = None + raise_meos_exception(error_level, error, error_message) @_ffi.def_extern() -def py_error_handler(error_code, error_msg): - global _error - _error = _ffi.string(error_msg).decode('utf-8') +def py_error_handler(error_level, error_code, error_msg): + global _error, _error_level, _error_message + _error = error_code + _error_level = error_level + _error_message = _ffi.string(error_msg).decode('utf-8') def create_pointer(object: 'Any', type: str) -> 'Any *': return _ffi.new(f'{type} *', object) - + def get_address(value: 'Any') -> 'Any *': return _ffi.addressof(value) @@ -58,7 +67,7 @@ def geometry_to_gserialized(geom: Union[pg.Geometry, BaseGeometry], geodetic: Op if isinstance(geom, pg.Geometry): text = geom.to_ewkb() # if geom.has_srid(): - # text = f'SRID={geom.srid};{text}' + # text = f'SRID={geom.srid};{text}' elif isinstance(geom, BaseGeometry): text = wkb.dumps(geom, hex=True) if get_srid(geom) > 0: @@ -113,12 +122,6 @@ def as_tsequenceset(temporal: 'Temporal *') -> 'TSequenceSet *': # ----------------------End of manually-defined functions---------------------- # ----------------------------------------------------------------------------- -def meos_initialize(tz_str: "Optional[str]") -> None: - tz_str_converted = tz_str.encode('utf-8') if tz_str is not None else _ffi.NULL - _lib.meos_initialize(tz_str_converted, _lib.py_error_handler) - - - def lwpoint_make(srid: 'int32_t', hasz: int, hasm: int, p: 'const POINT4D *') -> 'LWPOINT *': srid_converted = _ffi.cast('int32_t', srid) p_converted = _ffi.cast('const POINT4D *', p) @@ -191,6 +194,28 @@ def lwgeom_has_m(geom: 'const LWGEOM *') -> 'int': return result if result != _ffi.NULL else None +def meos_initialize_timezone(name: str) -> None: + name_converted = name.encode('utf-8') + _lib.meos_initialize_timezone(name_converted) + _check_error() + + +def meos_initialize_error_handler(err_handler: 'error_handler_fn') -> None: + err_handler_converted = _ffi.cast('error_handler_fn', err_handler) + _lib.meos_initialize_error_handler(err_handler_converted) + _check_error() + + +def meos_finalize_timezone() -> None: + _lib.meos_finalize_timezone() + _check_error() + + +def meos_initialize(tz_str: "Optional[str]") -> None: + tz_str_converted = tz_str.encode('utf-8') if tz_str is not None else _ffi.NULL + _lib.meos_initialize(tz_str_converted, _lib.py_error_handler) + + def meos_finalize() -> None: _lib.meos_finalize() _check_error() @@ -403,43 +428,57 @@ def pg_to_date(date_txt: str, fmt: str) -> 'DateADT': return result if result != _ffi.NULL else None -def gserialized_as_ewkb(geom: 'const GSERIALIZED *', type: str) -> 'bytea *': - geom_converted = _ffi.cast('const GSERIALIZED *', geom) +def geography_from_hexewkb(wkt: str) -> 'GSERIALIZED *': + wkt_converted = wkt.encode('utf-8') + result = _lib.geography_from_hexewkb(wkt_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def geometry_from_hexewkb(wkt: str) -> 'GSERIALIZED *': + wkt_converted = wkt.encode('utf-8') + result = _lib.geometry_from_hexewkb(wkt_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def gserialized_as_ewkb(gs: 'const GSERIALIZED *', type: str) -> 'bytea *': + gs_converted = _ffi.cast('const GSERIALIZED *', gs) type_converted = type.encode('utf-8') - result = _lib.gserialized_as_ewkb(geom_converted, type_converted) + result = _lib.gserialized_as_ewkb(gs_converted, type_converted) _check_error() return result if result != _ffi.NULL else None -def gserialized_as_ewkt(geom: 'const GSERIALIZED *', precision: int) -> str: - geom_converted = _ffi.cast('const GSERIALIZED *', geom) - result = _lib.gserialized_as_ewkt(geom_converted, precision) +def gserialized_as_ewkt(gs: 'const GSERIALIZED *', precision: int) -> str: + gs_converted = _ffi.cast('const GSERIALIZED *', gs) + result = _lib.gserialized_as_ewkt(gs_converted, precision) _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None -def gserialized_as_geojson(geom: 'const GSERIALIZED *', option: int, precision: int, srs: "Optional[str]") -> str: - geom_converted = _ffi.cast('const GSERIALIZED *', geom) +def gserialized_as_geojson(gs: 'const GSERIALIZED *', option: int, precision: int, srs: "Optional[str]") -> str: + gs_converted = _ffi.cast('const GSERIALIZED *', gs) srs_converted = srs.encode('utf-8') if srs is not None else _ffi.NULL - result = _lib.gserialized_as_geojson(geom_converted, option, precision, srs_converted) + result = _lib.gserialized_as_geojson(gs_converted, option, precision, srs_converted) _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None -def gserialized_as_hexewkb(geom: 'const GSERIALIZED *', type: str) -> str: - geom_converted = _ffi.cast('const GSERIALIZED *', geom) +def gserialized_as_hexewkb(gs: 'const GSERIALIZED *', type: str) -> str: + gs_converted = _ffi.cast('const GSERIALIZED *', gs) type_converted = type.encode('utf-8') - result = _lib.gserialized_as_hexewkb(geom_converted, type_converted) + result = _lib.gserialized_as_hexewkb(gs_converted, type_converted) _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None -def gserialized_as_text(geom: 'const GSERIALIZED *', precision: int) -> str: - geom_converted = _ffi.cast('const GSERIALIZED *', geom) - result = _lib.gserialized_as_text(geom_converted, precision) +def gserialized_as_text(gs: 'const GSERIALIZED *', precision: int) -> str: + gs_converted = _ffi.cast('const GSERIALIZED *', gs) + result = _lib.gserialized_as_text(gs_converted, precision) _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -460,40 +499,48 @@ def gserialized_from_geojson(geojson: str) -> 'GSERIALIZED *': return result if result != _ffi.NULL else None -def gserialized_from_hexewkb(wkt: str) -> 'GSERIALIZED *': +def gserialized_out(gs: 'const GSERIALIZED *') -> str: + gs_converted = _ffi.cast('const GSERIALIZED *', gs) + result = _lib.gserialized_out(gs_converted) + _check_error() + result = _ffi.string(result).decode('utf-8') + return result if result != _ffi.NULL else None + + +def geometry_from_text(wkt: str, srid: int) -> 'GSERIALIZED *': wkt_converted = wkt.encode('utf-8') - result = _lib.gserialized_from_hexewkb(wkt_converted) + result = _lib.geometry_from_text(wkt_converted, srid) _check_error() return result if result != _ffi.NULL else None -def gserialized_from_text(wkt: str, srid: int) -> 'GSERIALIZED *': +def geography_from_text(wkt: str, srid: int) -> 'GSERIALIZED *': wkt_converted = wkt.encode('utf-8') - result = _lib.gserialized_from_text(wkt_converted, srid) + result = _lib.geography_from_text(wkt_converted, srid) _check_error() return result if result != _ffi.NULL else None -def gserialized_in(input: str, geom_typmod: int) -> 'GSERIALIZED *': +def pgis_geography_in(input: str, geom_typmod: int) -> 'GSERIALIZED *': input_converted = input.encode('utf-8') geom_typmod_converted = _ffi.cast('int32', geom_typmod) - result = _lib.gserialized_in(input_converted, geom_typmod_converted) + result = _lib.pgis_geography_in(input_converted, geom_typmod_converted) _check_error() return result if result != _ffi.NULL else None -def gserialized_out(geom: 'const GSERIALIZED *') -> str: - geom_converted = _ffi.cast('const GSERIALIZED *', geom) - result = _lib.gserialized_out(geom_converted) +def pgis_geometry_in(input: str, geom_typmod: int) -> 'GSERIALIZED *': + input_converted = input.encode('utf-8') + geom_typmod_converted = _ffi.cast('int32', geom_typmod) + result = _lib.pgis_geometry_in(input_converted, geom_typmod_converted) _check_error() - result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None -def pgis_gserialized_same(geom1: 'const GSERIALIZED *', geom2: 'const GSERIALIZED *') -> 'bool': - geom1_converted = _ffi.cast('const GSERIALIZED *', geom1) +def pgis_gserialized_same(gs1: 'const GSERIALIZED *', geom2: 'const GSERIALIZED *') -> 'bool': + gs1_converted = _ffi.cast('const GSERIALIZED *', gs1) geom2_converted = _ffi.cast('const GSERIALIZED *', geom2) - result = _lib.pgis_gserialized_same(geom1_converted, geom2_converted) + result = _lib.pgis_gserialized_same(gs1_converted, geom2_converted) _check_error() return result if result != _ffi.NULL else None @@ -595,9 +642,9 @@ def geogset_in(string: str) -> 'Set *': return result if result != _ffi.NULL else None -def geogset_out(set: 'const Set *', maxdd: int) -> str: +def geoset_out(set: 'const Set *', maxdd: int) -> str: set_converted = _ffi.cast('const Set *', set) - result = _lib.geogset_out(set_converted, maxdd) + result = _lib.geoset_out(set_converted, maxdd) _check_error() result = _ffi.string(result).decode('utf-8') return result if result != _ffi.NULL else None @@ -610,14 +657,6 @@ def geomset_in(string: str) -> 'Set *': return result if result != _ffi.NULL else None -def geomset_out(set: 'const Set *', maxdd: int) -> str: - set_converted = _ffi.cast('const Set *', set) - result = _lib.geomset_out(set_converted, maxdd) - _check_error() - result = _ffi.string(result).decode('utf-8') - return result if result != _ffi.NULL else None - - def geoset_as_ewkt(set: 'const Set *', maxdd: int) -> str: set_converted = _ffi.cast('const Set *', set) result = _lib.geoset_as_ewkt(set_converted, maxdd) @@ -890,16 +929,9 @@ def floatspan_make(lower: float, upper: float, lower_inc: bool, upper_inc: bool) return result if result != _ffi.NULL else None -def geogset_make(values: 'const GSERIALIZED **', count: int) -> 'Set *': +def geoset_make(values: 'const GSERIALIZED **', count: int) -> 'Set *': values_converted = [_ffi.cast('const GSERIALIZED *', x) for x in values] - result = _lib.geogset_make(values_converted, count) - _check_error() - return result if result != _ffi.NULL else None - - -def geomset_make(values: 'const GSERIALIZED **', count: int) -> 'Set *': - values_converted = [_ffi.cast('const GSERIALIZED *', x) for x in values] - result = _lib.geomset_make(values_converted, count) + result = _lib.geoset_make(values_converted, count) _check_error() return result if result != _ffi.NULL else None @@ -960,13 +992,6 @@ def spanset_make_exp(spans: 'Span *', count: int, maxcount: int, normalize: bool return result if result != _ffi.NULL else None -def spanset_make_free(spans: 'Span *', count: int, normalize: bool) -> 'SpanSet *': - spans_converted = _ffi.cast('Span *', spans) - result = _lib.spanset_make_free(spans_converted, count, normalize) - _check_error() - return result if result != _ffi.NULL else None - - def textset_make(values: 'const text **', count: int) -> 'Set *': values_converted = [_ffi.cast('const text *', x) for x in values] result = _lib.textset_make(values_converted, count) @@ -1018,6 +1043,13 @@ def float_to_floatspanset(d: float) -> 'SpanSet *': return result if result != _ffi.NULL else None +def geo_to_geoset(gs: 'GSERIALIZED *') -> 'Set *': + gs_converted = _ffi.cast('GSERIALIZED *', gs) + result = _lib.geo_to_geoset(gs_converted) + _check_error() + return result if result != _ffi.NULL else None + + def int_to_intset(i: int) -> 'Set *': result = _lib.int_to_intset(i) _check_error() @@ -1050,6 +1082,13 @@ def span_to_spanset(s: 'const Span *') -> 'SpanSet *': return result if result != _ffi.NULL else None +def text_to_textset(txt: str) -> 'Set *': + txt_converted = cstring2text(txt) + result = _lib.text_to_textset(txt_converted) + _check_error() + return result if result != _ffi.NULL else None + + def timestamp_to_period(t: int) -> 'Span *': t_converted = _ffi.cast('TimestampTz', t) result = _lib.timestamp_to_period(t_converted) @@ -1189,6 +1228,13 @@ def floatspanset_upper(ss: 'const SpanSet *') -> 'double': return result if result != _ffi.NULL else None +def geoset_end_value(s: 'const Set *') -> 'GSERIALIZED *': + s_converted = _ffi.cast('const Set *', s) + result = _lib.geoset_end_value(s_converted) + _check_error() + return result if result != _ffi.NULL else None + + def geoset_srid(set: 'const Set *') -> 'int': set_converted = _ffi.cast('const Set *', set) result = _lib.geoset_srid(set_converted) @@ -1196,6 +1242,30 @@ def geoset_srid(set: 'const Set *') -> 'int': return result if result != _ffi.NULL else None +def geoset_start_value(s: 'const Set *') -> 'GSERIALIZED *': + s_converted = _ffi.cast('const Set *', s) + result = _lib.geoset_start_value(s_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def geoset_value_n(s: 'const Set *', n: int) -> 'GSERIALIZED **': + s_converted = _ffi.cast('const Set *', s) + out_result = _ffi.new('GSERIALIZED **') + result = _lib.geoset_value_n(s_converted, n, out_result) + _check_error() + if result: + return out_result if out_result != _ffi.NULL else None + return None + + +def geoset_values(s: 'const Set *') -> 'GSERIALIZED **': + s_converted = _ffi.cast('const Set *', s) + result = _lib.geoset_values(s_converted) + _check_error() + return result if result != _ffi.NULL else None + + def intset_end_value(s: 'const Set *') -> 'int': s_converted = _ffi.cast('const Set *', s) result = _lib.intset_end_value(s_converted) @@ -1500,6 +1570,39 @@ def spatialset_stbox(s: 'const Set *') -> 'STBox *': return result if result != _ffi.NULL else None +def textset_end_value(s: 'const Set *') -> str: + s_converted = _ffi.cast('const Set *', s) + result = _lib.textset_end_value(s_converted) + _check_error() + result = text2cstring(result) + return result if result != _ffi.NULL else None + + +def textset_start_value(s: 'const Set *') -> str: + s_converted = _ffi.cast('const Set *', s) + result = _lib.textset_start_value(s_converted) + _check_error() + result = text2cstring(result) + return result if result != _ffi.NULL else None + + +def textset_value_n(s: 'const Set *', n: int) -> 'text **': + s_converted = _ffi.cast('const Set *', s) + out_result = _ffi.new('text **') + result = _lib.textset_value_n(s_converted, n, out_result) + _check_error() + if result: + return out_result if out_result != _ffi.NULL else None + return None + + +def textset_values(s: 'const Set *') -> 'text **': + s_converted = _ffi.cast('const Set *', s) + result = _lib.textset_values(s_converted) + _check_error() + return result if result != _ffi.NULL else None + + def timestampset_end_timestamp(ts: 'const Set *') -> 'TimestampTz': ts_converted = _ffi.cast('const Set *', ts) result = _lib.timestampset_end_timestamp(ts_converted) @@ -1552,13 +1655,6 @@ def floatspanset_round(ss: 'const SpanSet *', maxdd: int) -> 'SpanSet *': return result if result != _ffi.NULL else None -def floatspan_set_intspan(s1: 'const Span *', s2: 'Span *') -> None: - s1_converted = _ffi.cast('const Span *', s1) - s2_converted = _ffi.cast('Span *', s2) - _lib.floatspan_set_intspan(s1_converted, s2_converted) - _check_error() - - def geoset_round(s: 'const Set *', maxdd: int) -> 'Set *': s_converted = _ffi.cast('const Set *', s) result = _lib.geoset_round(s_converted, maxdd) @@ -1566,13 +1662,6 @@ def geoset_round(s: 'const Set *', maxdd: int) -> 'Set *': return result if result != _ffi.NULL else None -def intspan_set_floatspan(s1: 'const Span *', s2: 'Span *') -> None: - s1_converted = _ffi.cast('const Span *', s1) - s2_converted = _ffi.cast('Span *', s2) - _lib.intspan_set_floatspan(s1_converted, s2_converted) - _check_error() - - def period_tprecision(s: 'const Span *', duration: 'const Interval *', torigin: int) -> 'Span *': s_converted = _ffi.cast('const Span *', s) duration_converted = _ffi.cast('const Interval *', duration) @@ -1609,21 +1698,6 @@ def periodset_shift_tscale(ps: 'const SpanSet *', shift: "Optional['const Interv return result if result != _ffi.NULL else None -def set_shift(s: 'const Set *', shift: 'Datum') -> 'Set *': - s_converted = _ffi.cast('const Set *', s) - shift_converted = _ffi.cast('Datum', shift) - result = _lib.set_shift(s_converted, shift_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def span_expand(s1: 'const Span *', s2: 'Span *') -> None: - s1_converted = _ffi.cast('const Span *', s1) - s2_converted = _ffi.cast('Span *', s2) - _lib.span_expand(s1_converted, s2_converted) - _check_error() - - def timestamp_tprecision(t: int, duration: 'const Interval *', torigin: int) -> 'TimestampTz': t_converted = _ffi.cast('TimestampTz', t) duration_converted = _ffi.cast('const Interval *', duration) @@ -2410,46 +2484,129 @@ def right_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'bo return result if result != _ffi.NULL else None -def bbox_union_span_span(s1: 'const Span *', s2: 'const Span *') -> 'Span *': - s1_converted = _ffi.cast('const Span *', s1) - s2_converted = _ffi.cast('const Span *', s2) - out_result = _ffi.new('Span *') - _lib.bbox_union_span_span(s1_converted, s2_converted, out_result) +def intersection_bigintset_bigint(s: 'const Set *', i: int) -> 'int64': + s_converted = _ffi.cast('const Set *', s) + i_converted = _ffi.cast('int64', i) + out_result = _ffi.new('int64 *') + result = _lib.intersection_bigintset_bigint(s_converted, i_converted, out_result) _check_error() - return out_result if out_result!= _ffi.NULL else None + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None +def intersection_bigintspan_bigint(s: 'const Span *', i: int) -> 'int64': + s_converted = _ffi.cast('const Span *', s) + i_converted = _ffi.cast('int64', i) + out_result = _ffi.new('int64 *') + result = _lib.intersection_bigintspan_bigint(s_converted, i_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None -def intersection_set_set(s1: 'const Set *', s2: 'const Set *') -> 'Set *': - s1_converted = _ffi.cast('const Set *', s1) - s2_converted = _ffi.cast('const Set *', s2) - result = _lib.intersection_set_set(s1_converted, s2_converted) + +def intersection_bigintspanset_bigint(ss: 'const SpanSet *', i: int) -> 'int64': + ss_converted = _ffi.cast('const SpanSet *', ss) + i_converted = _ffi.cast('int64', i) + out_result = _ffi.new('int64 *') + result = _lib.intersection_bigintspanset_bigint(ss_converted, i_converted, out_result) _check_error() - return result if result != _ffi.NULL else None + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None -def intersection_period_timestamp(p: 'const Span *', t: int) -> int: - p_converted = _ffi.cast('const Span *', p) +def intersection_floatset_float(s: 'const Set *', d: float) -> 'double': + s_converted = _ffi.cast('const Set *', s) + out_result = _ffi.new('double *') + result = _lib.intersection_floatset_float(s_converted, d, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def intersection_floatspan_float(s: 'const Span *', d: float) -> 'double': + s_converted = _ffi.cast('const Span *', s) + out_result = _ffi.new('double *') + result = _lib.intersection_floatspan_float(s_converted, d, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def intersection_floatspanset_float(ss: 'const SpanSet *', d: float) -> 'double': + ss_converted = _ffi.cast('const SpanSet *', ss) + out_result = _ffi.new('double *') + result = _lib.intersection_floatspanset_float(ss_converted, d, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def intersection_intset_int(s: 'const Set *', i: int) -> 'int': + s_converted = _ffi.cast('const Set *', s) + out_result = _ffi.new('int *') + result = _lib.intersection_intset_int(s_converted, i, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def intersection_intspan_int(s: 'const Span *', i: int) -> 'int': + s_converted = _ffi.cast('const Span *', s) + out_result = _ffi.new('int *') + result = _lib.intersection_intspan_int(s_converted, i, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def intersection_intspanset_int(ss: 'const SpanSet *', i: int) -> 'int': + ss_converted = _ffi.cast('const SpanSet *', ss) + out_result = _ffi.new('int *') + result = _lib.intersection_intspanset_int(ss_converted, i, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def intersection_period_timestamp(s: 'const Span *', t: int) -> int: + s_converted = _ffi.cast('const Span *', s) t_converted = _ffi.cast('TimestampTz', t) out_result = _ffi.new('TimestampTz *') - result = _lib.intersection_period_timestamp(p_converted, t_converted, out_result) + result = _lib.intersection_period_timestamp(s_converted, t_converted, out_result) _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None -def intersection_periodset_timestamp(ps: 'const SpanSet *', t: int) -> int: - ps_converted = _ffi.cast('const SpanSet *', ps) +def intersection_periodset_timestamp(ss: 'const SpanSet *', t: int) -> int: + ss_converted = _ffi.cast('const SpanSet *', ss) t_converted = _ffi.cast('TimestampTz', t) out_result = _ffi.new('TimestampTz *') - result = _lib.intersection_periodset_timestamp(ps_converted, t_converted, out_result) + result = _lib.intersection_periodset_timestamp(ss_converted, t_converted, out_result) _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None +def intersection_set_set(s1: 'const Set *', s2: 'const Set *') -> 'Set *': + s1_converted = _ffi.cast('const Set *', s1) + s2_converted = _ffi.cast('const Set *', s2) + result = _lib.intersection_set_set(s1_converted, s2_converted) + _check_error() + return result if result != _ffi.NULL else None + + def intersection_span_span(s1: 'const Span *', s2: 'const Span *') -> 'Span *': s1_converted = _ffi.cast('const Span *', s1) s2_converted = _ffi.cast('const Span *', s2) @@ -2471,126 +2628,381 @@ def intersection_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') ss2_converted = _ffi.cast('const SpanSet *', ss2) result = _lib.intersection_spanset_spanset(ss1_converted, ss2_converted) _check_error() - return result if result != _ffi.NULL else None + return result if result != _ffi.NULL else None + + +def intersection_textset_text(s: 'const Set *', txt: str) -> 'text **': + s_converted = _ffi.cast('const Set *', s) + txt_converted = cstring2text(txt) + out_result = _ffi.new('text **') + result = _lib.intersection_textset_text(s_converted, txt_converted, out_result) + _check_error() + if result: + return out_result if out_result != _ffi.NULL else None + return None + + +def intersection_timestampset_timestamp(s: 'const Set *', t: int) -> int: + s_converted = _ffi.cast('const Set *', s) + t_converted = _ffi.cast('TimestampTz', t) + out_result = _ffi.new('TimestampTz *') + result = _lib.intersection_timestampset_timestamp(s_converted, t_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def minus_bigint_bigintset(i: int, s: 'const Set *') -> 'int64': + i_converted = _ffi.cast('int64', i) + s_converted = _ffi.cast('const Set *', s) + out_result = _ffi.new('int64 *') + result = _lib.minus_bigint_bigintset(i_converted, s_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def minus_bigint_bigintspan(i: int, s: 'const Span *') -> 'int64': + i_converted = _ffi.cast('int64', i) + s_converted = _ffi.cast('const Span *', s) + out_result = _ffi.new('int64 *') + result = _lib.minus_bigint_bigintspan(i_converted, s_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def minus_bigint_bigintspanset(i: int, ss: 'const SpanSet *') -> 'int64': + i_converted = _ffi.cast('int64', i) + ss_converted = _ffi.cast('const SpanSet *', ss) + out_result = _ffi.new('int64 *') + result = _lib.minus_bigint_bigintspanset(i_converted, ss_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def minus_bigintset_bigint(s: 'const Set *', i: int) -> 'Set *': + s_converted = _ffi.cast('const Set *', s) + i_converted = _ffi.cast('int64', i) + result = _lib.minus_bigintset_bigint(s_converted, i_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_bigintspan_bigint(s: 'const Span *', i: int) -> 'SpanSet *': + s_converted = _ffi.cast('const Span *', s) + i_converted = _ffi.cast('int64', i) + result = _lib.minus_bigintspan_bigint(s_converted, i_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_bigintspanset_bigint(ss: 'const SpanSet *', i: int) -> 'SpanSet *': + ss_converted = _ffi.cast('const SpanSet *', ss) + i_converted = _ffi.cast('int64', i) + result = _lib.minus_bigintspanset_bigint(ss_converted, i_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_float_floatset(d: float, s: 'const Set *') -> 'double': + s_converted = _ffi.cast('const Set *', s) + out_result = _ffi.new('double *') + result = _lib.minus_float_floatset(d, s_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def minus_float_floatspan(d: float, s: 'const Span *') -> 'double': + s_converted = _ffi.cast('const Span *', s) + out_result = _ffi.new('double *') + result = _lib.minus_float_floatspan(d, s_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def minus_float_floatspanset(d: float, ss: 'const SpanSet *') -> 'double': + ss_converted = _ffi.cast('const SpanSet *', ss) + out_result = _ffi.new('double *') + result = _lib.minus_float_floatspanset(d, ss_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def minus_floatset_float(s: 'const Set *', d: float) -> 'Set *': + s_converted = _ffi.cast('const Set *', s) + result = _lib.minus_floatset_float(s_converted, d) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_floatspan_float(s: 'const Span *', d: float) -> 'SpanSet *': + s_converted = _ffi.cast('const Span *', s) + result = _lib.minus_floatspan_float(s_converted, d) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_floatspanset_float(ss: 'const SpanSet *', d: float) -> 'SpanSet *': + ss_converted = _ffi.cast('const SpanSet *', ss) + result = _lib.minus_floatspanset_float(ss_converted, d) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_int_intset(i: int, s: 'const Set *') -> 'int': + s_converted = _ffi.cast('const Set *', s) + out_result = _ffi.new('int *') + result = _lib.minus_int_intset(i, s_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def minus_int_intspan(i: int, s: 'const Span *') -> 'int': + s_converted = _ffi.cast('const Span *', s) + out_result = _ffi.new('int *') + result = _lib.minus_int_intspan(i, s_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def minus_int_intspanset(i: int, ss: 'const SpanSet *') -> 'int': + ss_converted = _ffi.cast('const SpanSet *', ss) + out_result = _ffi.new('int *') + result = _lib.minus_int_intspanset(i, ss_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None + + +def minus_intset_int(s: 'const Set *', i: int) -> 'Set *': + s_converted = _ffi.cast('const Set *', s) + result = _lib.minus_intset_int(s_converted, i) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_intspan_int(s: 'const Span *', i: int) -> 'SpanSet *': + s_converted = _ffi.cast('const Span *', s) + result = _lib.minus_intspan_int(s_converted, i) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_intspanset_int(ss: 'const SpanSet *', i: int) -> 'SpanSet *': + ss_converted = _ffi.cast('const SpanSet *', ss) + result = _lib.minus_intspanset_int(ss_converted, i) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_period_timestamp(s: 'const Span *', t: int) -> 'SpanSet *': + s_converted = _ffi.cast('const Span *', s) + t_converted = _ffi.cast('TimestampTz', t) + result = _lib.minus_period_timestamp(s_converted, t_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_periodset_timestamp(ss: 'const SpanSet *', t: int) -> 'SpanSet *': + ss_converted = _ffi.cast('const SpanSet *', ss) + t_converted = _ffi.cast('TimestampTz', t) + result = _lib.minus_periodset_timestamp(ss_converted, t_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_set_set(s1: 'const Set *', s2: 'const Set *') -> 'Set *': + s1_converted = _ffi.cast('const Set *', s1) + s2_converted = _ffi.cast('const Set *', s2) + result = _lib.minus_set_set(s1_converted, s2_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_span_span(s1: 'const Span *', s2: 'const Span *') -> 'SpanSet *': + s1_converted = _ffi.cast('const Span *', s1) + s2_converted = _ffi.cast('const Span *', s2) + result = _lib.minus_span_span(s1_converted, s2_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_span_spanset(s: 'const Span *', ss: 'const SpanSet *') -> 'SpanSet *': + s_converted = _ffi.cast('const Span *', s) + ss_converted = _ffi.cast('const SpanSet *', ss) + result = _lib.minus_span_spanset(s_converted, ss_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'SpanSet *': + ss_converted = _ffi.cast('const SpanSet *', ss) + s_converted = _ffi.cast('const Span *', s) + result = _lib.minus_spanset_span(ss_converted, s_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'SpanSet *': + ss1_converted = _ffi.cast('const SpanSet *', ss1) + ss2_converted = _ffi.cast('const SpanSet *', ss2) + result = _lib.minus_spanset_spanset(ss1_converted, ss2_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_text_textset(txt: str, s: 'const Set *') -> 'text **': + txt_converted = cstring2text(txt) + s_converted = _ffi.cast('const Set *', s) + out_result = _ffi.new('text **') + result = _lib.minus_text_textset(txt_converted, s_converted, out_result) + _check_error() + if result: + return out_result if out_result != _ffi.NULL else None + return None + + +def minus_textset_text(s: 'const Set *', txt: str) -> 'Set *': + s_converted = _ffi.cast('const Set *', s) + txt_converted = cstring2text(txt) + result = _lib.minus_textset_text(s_converted, txt_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def minus_timestamp_period(t: int, s: 'const Span *') -> int: + t_converted = _ffi.cast('TimestampTz', t) + s_converted = _ffi.cast('const Span *', s) + out_result = _ffi.new('TimestampTz *') + result = _lib.minus_timestamp_period(t_converted, s_converted, out_result) + _check_error() + if result: + return out_result[0] if out_result[0] != _ffi.NULL else None + return None -def intersection_timestampset_timestamp(ts: 'const Set *', t: int) -> int: - ts_converted = _ffi.cast('const Set *', ts) - t_converted = _ffi.cast('const TimestampTz', t) +def minus_timestamp_periodset(t: int, ss: 'const SpanSet *') -> int: + t_converted = _ffi.cast('TimestampTz', t) + ss_converted = _ffi.cast('const SpanSet *', ss) out_result = _ffi.new('TimestampTz *') - result = _lib.intersection_timestampset_timestamp(ts_converted, t_converted, out_result) + result = _lib.minus_timestamp_periodset(t_converted, ss_converted, out_result) _check_error() if result: return out_result[0] if out_result[0] != _ffi.NULL else None return None -def minus_set_set(s1: 'const Set *', s2: 'const Set *') -> 'Set *': - s1_converted = _ffi.cast('const Set *', s1) - s2_converted = _ffi.cast('const Set *', s2) - result = _lib.minus_set_set(s1_converted, s2_converted) +def minus_timestampset_timestamp(s: 'const Set *', t: int) -> 'Set *': + s_converted = _ffi.cast('const Set *', s) + t_converted = _ffi.cast('TimestampTz', t) + result = _lib.minus_timestampset_timestamp(s_converted, t_converted) _check_error() return result if result != _ffi.NULL else None -def minus_period_timestamp(p: 'const Span *', t: int) -> 'SpanSet *': - p_converted = _ffi.cast('const Span *', p) - t_converted = _ffi.cast('TimestampTz', t) - result = _lib.minus_period_timestamp(p_converted, t_converted) +def union_bigintset_bigint(s: 'const Set *', i: int) -> 'Set *': + s_converted = _ffi.cast('const Set *', s) + i_converted = _ffi.cast('int64', i) + result = _lib.union_bigintset_bigint(s_converted, i_converted) _check_error() return result if result != _ffi.NULL else None -def minus_periodset_timestamp(ps: 'const SpanSet *', t: int) -> 'SpanSet *': - ps_converted = _ffi.cast('const SpanSet *', ps) - t_converted = _ffi.cast('TimestampTz', t) - result = _lib.minus_periodset_timestamp(ps_converted, t_converted) +def union_bigintspan_bigint(s: 'const Span *', i: int) -> 'SpanSet *': + s_converted = _ffi.cast('const Span *', s) + i_converted = _ffi.cast('int64', i) + result = _lib.union_bigintspan_bigint(s_converted, i_converted) _check_error() return result if result != _ffi.NULL else None -def minus_span_span(s1: 'const Span *', s2: 'const Span *') -> 'SpanSet *': - s1_converted = _ffi.cast('const Span *', s1) - s2_converted = _ffi.cast('const Span *', s2) - result = _lib.minus_span_span(s1_converted, s2_converted) +def union_bigintspanset_bigint(ss: 'const SpanSet *', i: int) -> 'SpanSet *': + ss_converted = _ffi.cast('const SpanSet *', ss) + i_converted = _ffi.cast('int64', i) + result = _lib.union_bigintspanset_bigint(ss_converted, i_converted) _check_error() return result if result != _ffi.NULL else None -def minus_span_spanset(s: 'const Span *', ss: 'const SpanSet *') -> 'SpanSet *': - s_converted = _ffi.cast('const Span *', s) - ss_converted = _ffi.cast('const SpanSet *', ss) - result = _lib.minus_span_spanset(s_converted, ss_converted) +def union_floatset_float(s: 'const Set *', d: float) -> 'Set *': + s_converted = _ffi.cast('const Set *', s) + result = _lib.union_floatset_float(s_converted, d) _check_error() return result if result != _ffi.NULL else None -def minus_spanset_span(ss: 'const SpanSet *', s: 'const Span *') -> 'SpanSet *': - ss_converted = _ffi.cast('const SpanSet *', ss) +def union_floatspan_float(s: 'const Span *', d: float) -> 'SpanSet *': s_converted = _ffi.cast('const Span *', s) - result = _lib.minus_spanset_span(ss_converted, s_converted) + result = _lib.union_floatspan_float(s_converted, d) _check_error() return result if result != _ffi.NULL else None -def minus_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'SpanSet *': - ss1_converted = _ffi.cast('const SpanSet *', ss1) - ss2_converted = _ffi.cast('const SpanSet *', ss2) - result = _lib.minus_spanset_spanset(ss1_converted, ss2_converted) +def union_floatspanset_float(ss: 'const SpanSet *', d: float) -> 'SpanSet *': + ss_converted = _ffi.cast('const SpanSet *', ss) + result = _lib.union_floatspanset_float(ss_converted, d) _check_error() return result if result != _ffi.NULL else None -def minus_timestamp_period(t: int, p: 'const Span *') -> int: - t_converted = _ffi.cast('TimestampTz', t) - p_converted = _ffi.cast('const Span *', p) - out_result = _ffi.new('TimestampTz *') - result = _lib.minus_timestamp_period(t_converted, p_converted, out_result) +def union_intset_int(s: 'const Set *', i: int) -> 'Set *': + s_converted = _ffi.cast('const Set *', s) + result = _lib.union_intset_int(s_converted, i) _check_error() - if result: - return out_result[0] if out_result[0] != _ffi.NULL else None - return None + return result if result != _ffi.NULL else None -def minus_timestamp_periodset(t: int, ps: 'const SpanSet *') -> int: - t_converted = _ffi.cast('TimestampTz', t) - ps_converted = _ffi.cast('const SpanSet *', ps) - out_result = _ffi.new('TimestampTz *') - result = _lib.minus_timestamp_periodset(t_converted, ps_converted, out_result) +def union_intspan_int(s: 'const Span *', i: int) -> 'SpanSet *': + s_converted = _ffi.cast('const Span *', s) + result = _lib.union_intspan_int(s_converted, i) _check_error() - if result: - return out_result[0] if out_result[0] != _ffi.NULL else None - return None + return result if result != _ffi.NULL else None -def minus_timestampset_timestamp(ts: 'const Set *', t: int) -> 'Set *': - ts_converted = _ffi.cast('const Set *', ts) - t_converted = _ffi.cast('TimestampTz', t) - result = _lib.minus_timestampset_timestamp(ts_converted, t_converted) +def union_intspanset_int(ss: 'const SpanSet *', i: int) -> 'SpanSet *': + ss_converted = _ffi.cast('const SpanSet *', ss) + result = _lib.union_intspanset_int(ss_converted, i) _check_error() return result if result != _ffi.NULL else None -def union_set_set(s1: 'const Set *', s2: 'const Set *') -> 'Set *': - s1_converted = _ffi.cast('const Set *', s1) - s2_converted = _ffi.cast('const Set *', s2) - result = _lib.union_set_set(s1_converted, s2_converted) +def union_period_timestamp(s: 'const Span *', t: int) -> 'SpanSet *': + s_converted = _ffi.cast('const Span *', s) + t_converted = _ffi.cast('TimestampTz', t) + result = _lib.union_period_timestamp(s_converted, t_converted) _check_error() return result if result != _ffi.NULL else None -def union_period_timestamp(p: 'const Span *', t: int) -> 'SpanSet *': - p_converted = _ffi.cast('const Span *', p) +def union_periodset_timestamp(ss: 'SpanSet *', t: int) -> 'SpanSet *': + ss_converted = _ffi.cast('SpanSet *', ss) t_converted = _ffi.cast('TimestampTz', t) - result = _lib.union_period_timestamp(p_converted, t_converted) + result = _lib.union_periodset_timestamp(ss_converted, t_converted) _check_error() return result if result != _ffi.NULL else None -def union_periodset_timestamp(ps: 'SpanSet *', t: int) -> 'SpanSet *': - ps_converted = _ffi.cast('SpanSet *', ps) - t_converted = _ffi.cast('TimestampTz', t) - result = _lib.union_periodset_timestamp(ps_converted, t_converted) +def union_set_set(s1: 'const Set *', s2: 'const Set *') -> 'Set *': + s1_converted = _ffi.cast('const Set *', s1) + s2_converted = _ffi.cast('const Set *', s2) + result = _lib.union_set_set(s1_converted, s2_converted) _check_error() return result if result != _ffi.NULL else None @@ -2619,10 +3031,18 @@ def union_spanset_spanset(ss1: 'const SpanSet *', ss2: 'const SpanSet *') -> 'Sp return result if result != _ffi.NULL else None -def union_timestampset_timestamp(ts: 'const Set *', t: int) -> 'Set *': - ts_converted = _ffi.cast('const Set *', ts) +def union_textset_text(s: 'const Set *', txt: str) -> 'Set *': + s_converted = _ffi.cast('const Set *', s) + txt_converted = cstring2text(txt) + result = _lib.union_textset_text(s_converted, txt_converted) + _check_error() + return result if result != _ffi.NULL else None + + +def union_timestampset_timestamp(s: 'const Set *', t: int) -> 'Set *': + s_converted = _ffi.cast('const Set *', s) t_converted = _ffi.cast('const TimestampTz', t) - result = _lib.union_timestampset_timestamp(ts_converted, t_converted) + result = _lib.union_timestampset_timestamp(s_converted, t_converted) _check_error() return result if result != _ffi.NULL else None @@ -3123,48 +3543,32 @@ def stbox_out(box: 'const STBox *', maxdd: int) -> str: return result if result != _ffi.NULL else None -def tbox_make(s: "Optional['const Span *']", p: "Optional['const Span *']") -> 'TBox *': - s_converted = _ffi.cast('const Span *', s) if s is not None else _ffi.NULL +def stbox_make(hasx: bool, hasz: bool, geodetic: bool, srid: int, xmin: float, xmax: float, ymin: float, ymax: float, zmin: float, zmax: float, p: "Optional['const Span *']") -> 'STBox *': + srid_converted = _ffi.cast('int32', srid) p_converted = _ffi.cast('const Span *', p) if p is not None else _ffi.NULL - result = _lib.tbox_make(s_converted, p_converted) + result = _lib.stbox_make(hasx, hasz, geodetic, srid_converted, xmin, xmax, ymin, ymax, zmin, zmax, p_converted) _check_error() return result if result != _ffi.NULL else None -def tbox_set(s: 'const Span *', p: 'const Span *', box: 'TBox *') -> None: - s_converted = _ffi.cast('const Span *', s) - p_converted = _ffi.cast('const Span *', p) - box_converted = _ffi.cast('TBox *', box) - _lib.tbox_set(s_converted, p_converted, box_converted) - _check_error() - - -def tbox_copy(box: 'const TBox *') -> 'TBox *': - box_converted = _ffi.cast('const TBox *', box) - result = _lib.tbox_copy(box_converted) +def stbox_copy(box: 'const STBox *') -> 'STBox *': + box_converted = _ffi.cast('const STBox *', box) + result = _lib.stbox_copy(box_converted) _check_error() return result if result != _ffi.NULL else None -def stbox_make(hasx: bool, hasz: bool, geodetic: bool, srid: int, xmin: float, xmax: float, ymin: float, ymax: float, zmin: float, zmax: float, p: "Optional['const Span *']") -> 'STBox *': - srid_converted = _ffi.cast('int32', srid) +def tbox_make(s: "Optional['const Span *']", p: "Optional['const Span *']") -> 'TBox *': + s_converted = _ffi.cast('const Span *', s) if s is not None else _ffi.NULL p_converted = _ffi.cast('const Span *', p) if p is not None else _ffi.NULL - result = _lib.stbox_make(hasx, hasz, geodetic, srid_converted, xmin, xmax, ymin, ymax, zmin, zmax, p_converted) + result = _lib.tbox_make(s_converted, p_converted) _check_error() return result if result != _ffi.NULL else None -def stbox_set(hasx: bool, hasz: bool, geodetic: bool, srid: int, xmin: float, xmax: float, ymin: float, ymax: float, zmin: float, zmax: float, p: 'const Span *', box: 'STBox *') -> None: - srid_converted = _ffi.cast('int32', srid) - p_converted = _ffi.cast('const Span *', p) - box_converted = _ffi.cast('STBox *', box) - _lib.stbox_set(hasx, hasz, geodetic, srid_converted, xmin, xmax, ymin, ymax, zmin, zmax, p_converted, box_converted) - _check_error() - - -def stbox_copy(box: 'const STBox *') -> 'STBox *': - box_converted = _ffi.cast('const STBox *', box) - result = _lib.stbox_copy(box_converted) +def tbox_copy(box: 'const TBox *') -> 'TBox *': + box_converted = _ffi.cast('const TBox *', box) + result = _lib.tbox_copy(box_converted) _check_error() return result if result != _ffi.NULL else None @@ -3582,13 +3986,6 @@ def stbox_srid(box: 'const STBox *') -> 'int32': return result if result != _ffi.NULL else None -def stbox_expand(box1: 'const STBox *', box2: 'STBox *') -> None: - box1_converted = _ffi.cast('const STBox *', box1) - box2_converted = _ffi.cast('STBox *', box2) - _lib.stbox_expand(box1_converted, box2_converted) - _check_error() - - def stbox_expand_space(box: 'const STBox *', d: float) -> 'STBox *': box_converted = _ffi.cast('const STBox *', box) result = _lib.stbox_expand_space(box_converted, d) @@ -3626,13 +4023,6 @@ def stbox_set_srid(box: 'const STBox *', srid: int) -> 'STBox *': return result if result != _ffi.NULL else None -def tbox_expand(box1: 'const TBox *', box2: 'TBox *') -> None: - box1_converted = _ffi.cast('const TBox *', box1) - box2_converted = _ffi.cast('TBox *', box2) - _lib.tbox_expand(box1_converted, box2_converted) - _check_error() - - def tbox_expand_value(box: 'const TBox *', d: 'const double') -> 'TBox *': box_converted = _ffi.cast('const TBox *', box) d_converted = _ffi.cast('const double', d) @@ -4328,121 +4718,79 @@ def tfloatseqset_from_base_periodset(d: float, ps: 'const SpanSet *', interp: 'i return result if result != _ffi.NULL else None -def tgeogpoint_from_base_temp(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> 'Temporal *': - gs_converted = _ffi.cast('const GSERIALIZED *', gs) +def tint_from_base_temp(i: int, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) - result = _lib.tgeogpoint_from_base_temp(gs_converted, temp_converted) + result = _lib.tint_from_base_temp(i, temp_converted) _check_error() return result if result != _ffi.NULL else None -def tgeogpointinst_make(gs: 'const GSERIALIZED *', t: int) -> 'TInstant *': - gs_converted = _ffi.cast('const GSERIALIZED *', gs) +def tintinst_make(i: int, t: int) -> 'TInstant *': t_converted = _ffi.cast('TimestampTz', t) - result = _lib.tgeogpointinst_make(gs_converted, t_converted) + result = _lib.tintinst_make(i, t_converted) _check_error() return result if result != _ffi.NULL else None -def tgeogpointseq_from_base_period(gs: 'const GSERIALIZED *', p: 'const Span *', interp: 'interpType') -> 'TSequence *': - gs_converted = _ffi.cast('const GSERIALIZED *', gs) +def tintseq_from_base_period(i: int, p: 'const Span *') -> 'TSequence *': p_converted = _ffi.cast('const Span *', p) - interp_converted = _ffi.cast('interpType', interp) - result = _lib.tgeogpointseq_from_base_period(gs_converted, p_converted, interp_converted) + result = _lib.tintseq_from_base_period(i, p_converted) _check_error() return result if result != _ffi.NULL else None -def tgeogpointseq_from_base_timestampset(gs: 'const GSERIALIZED *', ts: 'const Set *') -> 'TSequence *': - gs_converted = _ffi.cast('const GSERIALIZED *', gs) +def tintseq_from_base_timestampset(i: int, ts: 'const Set *') -> 'TSequence *': ts_converted = _ffi.cast('const Set *', ts) - result = _lib.tgeogpointseq_from_base_timestampset(gs_converted, ts_converted) + result = _lib.tintseq_from_base_timestampset(i, ts_converted) _check_error() return result if result != _ffi.NULL else None -def tgeogpointseqset_from_base_periodset(gs: 'const GSERIALIZED *', ps: 'const SpanSet *', interp: 'interpType') -> 'TSequenceSet *': - gs_converted = _ffi.cast('const GSERIALIZED *', gs) +def tintseqset_from_base_periodset(i: int, ps: 'const SpanSet *') -> 'TSequenceSet *': ps_converted = _ffi.cast('const SpanSet *', ps) - interp_converted = _ffi.cast('interpType', interp) - result = _lib.tgeogpointseqset_from_base_periodset(gs_converted, ps_converted, interp_converted) + result = _lib.tintseqset_from_base_periodset(i, ps_converted) _check_error() return result if result != _ffi.NULL else None -def tgeompoint_from_base_temp(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> 'Temporal *': +def tpoint_from_base_temp(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> 'Temporal *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) temp_converted = _ffi.cast('const Temporal *', temp) - result = _lib.tgeompoint_from_base_temp(gs_converted, temp_converted) + result = _lib.tpoint_from_base_temp(gs_converted, temp_converted) _check_error() return result if result != _ffi.NULL else None -def tgeompointinst_make(gs: 'const GSERIALIZED *', t: int) -> 'TInstant *': +def tpointinst_make(gs: 'const GSERIALIZED *', t: int) -> 'TInstant *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) t_converted = _ffi.cast('TimestampTz', t) - result = _lib.tgeompointinst_make(gs_converted, t_converted) + result = _lib.tpointinst_make(gs_converted, t_converted) _check_error() return result if result != _ffi.NULL else None -def tgeompointseq_from_base_period(gs: 'const GSERIALIZED *', p: 'const Span *', interp: 'interpType') -> 'TSequence *': +def tpointseq_from_base_period(gs: 'const GSERIALIZED *', p: 'const Span *', interp: 'interpType') -> 'TSequence *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) p_converted = _ffi.cast('const Span *', p) interp_converted = _ffi.cast('interpType', interp) - result = _lib.tgeompointseq_from_base_period(gs_converted, p_converted, interp_converted) + result = _lib.tpointseq_from_base_period(gs_converted, p_converted, interp_converted) _check_error() return result if result != _ffi.NULL else None -def tgeompointseq_from_base_timestampset(gs: 'const GSERIALIZED *', ts: 'const Set *') -> 'TSequence *': +def tpointseq_from_base_timestampset(gs: 'const GSERIALIZED *', ts: 'const Set *') -> 'TSequence *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) ts_converted = _ffi.cast('const Set *', ts) - result = _lib.tgeompointseq_from_base_timestampset(gs_converted, ts_converted) + result = _lib.tpointseq_from_base_timestampset(gs_converted, ts_converted) _check_error() return result if result != _ffi.NULL else None -def tgeompointseqset_from_base_periodset(gs: 'const GSERIALIZED *', ps: 'const SpanSet *', interp: 'interpType') -> 'TSequenceSet *': +def tpointseqset_from_base_periodset(gs: 'const GSERIALIZED *', ps: 'const SpanSet *', interp: 'interpType') -> 'TSequenceSet *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) ps_converted = _ffi.cast('const SpanSet *', ps) interp_converted = _ffi.cast('interpType', interp) - result = _lib.tgeompointseqset_from_base_periodset(gs_converted, ps_converted, interp_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def tint_from_base_temp(i: int, temp: 'const Temporal *') -> 'Temporal *': - temp_converted = _ffi.cast('const Temporal *', temp) - result = _lib.tint_from_base_temp(i, temp_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def tintinst_make(i: int, t: int) -> 'TInstant *': - t_converted = _ffi.cast('TimestampTz', t) - result = _lib.tintinst_make(i, t_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def tintseq_from_base_period(i: int, p: 'const Span *') -> 'TSequence *': - p_converted = _ffi.cast('const Span *', p) - result = _lib.tintseq_from_base_period(i, p_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def tintseq_from_base_timestampset(i: int, ts: 'const Set *') -> 'TSequence *': - ts_converted = _ffi.cast('const Set *', ts) - result = _lib.tintseq_from_base_timestampset(i, ts_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def tintseqset_from_base_periodset(i: int, ps: 'const SpanSet *') -> 'TSequenceSet *': - ps_converted = _ffi.cast('const SpanSet *', ps) - result = _lib.tintseqset_from_base_periodset(i, ps_converted) + result = _lib.tpointseqset_from_base_periodset(gs_converted, ps_converted, interp_converted) _check_error() return result if result != _ffi.NULL else None @@ -4754,14 +5102,6 @@ def temporal_timestamps(temp: 'const Temporal *') -> "Tuple['TimestampTz *', 'in return result if result != _ffi.NULL else None, count[0] -def temporal_values(temp: 'const Temporal *') -> "Tuple['Datum *', 'int']": - temp_converted = _ffi.cast('const Temporal *', temp) - count = _ffi.new('int *') - result = _lib.temporal_values(temp_converted, count) - _check_error() - return result if result != _ffi.NULL else None, count[0] - - def tfloat_end_value(temp: 'const Temporal *') -> 'double': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tfloat_end_value(temp_converted) @@ -5889,38 +6229,6 @@ def tfloat_ever_lt(temp: 'const Temporal *', d: float) -> 'bool': return result if result != _ffi.NULL else None -def tgeogpoint_always_eq(temp: 'const Temporal *', gs: 'GSERIALIZED *') -> 'bool': - temp_converted = _ffi.cast('const Temporal *', temp) - gs_converted = _ffi.cast('GSERIALIZED *', gs) - result = _lib.tgeogpoint_always_eq(temp_converted, gs_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def tgeogpoint_ever_eq(temp: 'const Temporal *', gs: 'GSERIALIZED *') -> 'bool': - temp_converted = _ffi.cast('const Temporal *', temp) - gs_converted = _ffi.cast('GSERIALIZED *', gs) - result = _lib.tgeogpoint_ever_eq(temp_converted, gs_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def tgeompoint_always_eq(temp: 'const Temporal *', gs: 'GSERIALIZED *') -> 'bool': - temp_converted = _ffi.cast('const Temporal *', temp) - gs_converted = _ffi.cast('GSERIALIZED *', gs) - result = _lib.tgeompoint_always_eq(temp_converted, gs_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def tgeompoint_ever_eq(temp: 'const Temporal *', gs: 'GSERIALIZED *') -> 'bool': - temp_converted = _ffi.cast('const Temporal *', temp) - gs_converted = _ffi.cast('GSERIALIZED *', gs) - result = _lib.tgeompoint_ever_eq(temp_converted, gs_converted) - _check_error() - return result if result != _ffi.NULL else None - - def tint_always_eq(temp: 'const Temporal *', i: int) -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tint_always_eq(temp_converted, i) @@ -5963,18 +6271,18 @@ def tint_ever_lt(temp: 'const Temporal *', i: int) -> 'bool': return result if result != _ffi.NULL else None -def tpoint_always_eq(temp: 'const Temporal *', value: 'Datum') -> 'bool': +def tpoint_always_eq(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) - value_converted = _ffi.cast('Datum', value) - result = _lib.tpoint_always_eq(temp_converted, value_converted) + gs_converted = _ffi.cast('const GSERIALIZED *', gs) + result = _lib.tpoint_always_eq(temp_converted, gs_converted) _check_error() return result if result != _ffi.NULL else None -def tpoint_ever_eq(temp: 'const Temporal *', value: 'Datum') -> 'bool': +def tpoint_ever_eq(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> 'bool': temp_converted = _ffi.cast('const Temporal *', temp) - value_converted = _ffi.cast('Datum', value) - result = _lib.tpoint_ever_eq(temp_converted, value_converted) + gs_converted = _ffi.cast('const GSERIALIZED *', gs) + result = _lib.tpoint_ever_eq(temp_converted, gs_converted) _check_error() return result if result != _ffi.NULL else None @@ -6097,14 +6405,6 @@ def teq_float_tfloat(d: float, temp: 'const Temporal *') -> 'Temporal *': return result if result != _ffi.NULL else None -def teq_geo_tpoint(geo: 'const GSERIALIZED *', tpoint: 'const Temporal *') -> 'Temporal *': - geo_converted = _ffi.cast('const GSERIALIZED *', geo) - tpoint_converted = _ffi.cast('const Temporal *', tpoint) - result = _lib.teq_geo_tpoint(geo_converted, tpoint_converted) - _check_error() - return result if result != _ffi.NULL else None - - def teq_int_tint(i: int, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.teq_int_tint(i, temp_converted) @@ -6112,18 +6412,10 @@ def teq_int_tint(i: int, temp: 'const Temporal *') -> 'Temporal *': return result if result != _ffi.NULL else None -def teq_point_tgeogpoint(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> 'Temporal *': - gs_converted = _ffi.cast('const GSERIALIZED *', gs) - temp_converted = _ffi.cast('const Temporal *', temp) - result = _lib.teq_point_tgeogpoint(gs_converted, temp_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def teq_point_tgeompoint(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> 'Temporal *': +def teq_point_tpoint(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> 'Temporal *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) temp_converted = _ffi.cast('const Temporal *', temp) - result = _lib.teq_point_tgeompoint(gs_converted, temp_converted) + result = _lib.teq_point_tpoint(gs_converted, temp_converted) _check_error() return result if result != _ffi.NULL else None @@ -6158,18 +6450,10 @@ def teq_tfloat_float(temp: 'const Temporal *', d: float) -> 'Temporal *': return result if result != _ffi.NULL else None -def teq_tgeogpoint_point(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> 'Temporal *': - temp_converted = _ffi.cast('const Temporal *', temp) - gs_converted = _ffi.cast('const GSERIALIZED *', gs) - result = _lib.teq_tgeogpoint_point(temp_converted, gs_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def teq_tgeompoint_point(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> 'Temporal *': +def teq_tpoint_point(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) - result = _lib.teq_tgeompoint_point(temp_converted, gs_converted) + result = _lib.teq_tpoint_point(temp_converted, gs_converted) _check_error() return result if result != _ffi.NULL else None @@ -6181,14 +6465,6 @@ def teq_tint_int(temp: 'const Temporal *', i: int) -> 'Temporal *': return result if result != _ffi.NULL else None -def teq_tpoint_geo(tpoint: 'const Temporal *', geo: 'const GSERIALIZED *') -> 'Temporal *': - tpoint_converted = _ffi.cast('const Temporal *', tpoint) - geo_converted = _ffi.cast('const GSERIALIZED *', geo) - result = _lib.teq_tpoint_geo(tpoint_converted, geo_converted) - _check_error() - return result if result != _ffi.NULL else None - - def teq_ttext_text(temp: 'const Temporal *', txt: str) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) @@ -6419,14 +6695,6 @@ def tne_float_tfloat(d: float, temp: 'const Temporal *') -> 'Temporal *': return result if result != _ffi.NULL else None -def tne_geo_tpoint(geo: 'const GSERIALIZED *', tpoint: 'const Temporal *') -> 'Temporal *': - geo_converted = _ffi.cast('const GSERIALIZED *', geo) - tpoint_converted = _ffi.cast('const Temporal *', tpoint) - result = _lib.tne_geo_tpoint(geo_converted, tpoint_converted) - _check_error() - return result if result != _ffi.NULL else None - - def tne_int_tint(i: int, temp: 'const Temporal *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) result = _lib.tne_int_tint(i, temp_converted) @@ -6434,18 +6702,10 @@ def tne_int_tint(i: int, temp: 'const Temporal *') -> 'Temporal *': return result if result != _ffi.NULL else None -def tne_point_tgeogpoint(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> 'Temporal *': - gs_converted = _ffi.cast('const GSERIALIZED *', gs) - temp_converted = _ffi.cast('const Temporal *', temp) - result = _lib.tne_point_tgeogpoint(gs_converted, temp_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def tne_point_tgeompoint(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> 'Temporal *': +def tne_point_tpoint(gs: 'const GSERIALIZED *', temp: 'const Temporal *') -> 'Temporal *': gs_converted = _ffi.cast('const GSERIALIZED *', gs) temp_converted = _ffi.cast('const Temporal *', temp) - result = _lib.tne_point_tgeompoint(gs_converted, temp_converted) + result = _lib.tne_point_tpoint(gs_converted, temp_converted) _check_error() return result if result != _ffi.NULL else None @@ -6480,18 +6740,10 @@ def tne_tfloat_float(temp: 'const Temporal *', d: float) -> 'Temporal *': return result if result != _ffi.NULL else None -def tne_tgeogpoint_point(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> 'Temporal *': - temp_converted = _ffi.cast('const Temporal *', temp) - gs_converted = _ffi.cast('const GSERIALIZED *', gs) - result = _lib.tne_tgeogpoint_point(temp_converted, gs_converted) - _check_error() - return result if result != _ffi.NULL else None - - -def tne_tgeompoint_point(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> 'Temporal *': +def tne_tpoint_point(temp: 'const Temporal *', gs: 'const GSERIALIZED *') -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) gs_converted = _ffi.cast('const GSERIALIZED *', gs) - result = _lib.tne_tgeompoint_point(temp_converted, gs_converted) + result = _lib.tne_tpoint_point(temp_converted, gs_converted) _check_error() return result if result != _ffi.NULL else None @@ -6503,14 +6755,6 @@ def tne_tint_int(temp: 'const Temporal *', i: int) -> 'Temporal *': return result if result != _ffi.NULL else None -def tne_tpoint_geo(tpoint: 'const Temporal *', geo: 'const GSERIALIZED *') -> 'Temporal *': - tpoint_converted = _ffi.cast('const Temporal *', tpoint) - geo_converted = _ffi.cast('const GSERIALIZED *', geo) - result = _lib.tne_tpoint_geo(tpoint_converted, geo_converted) - _check_error() - return result if result != _ffi.NULL else None - - def tne_ttext_text(temp: 'const Temporal *', txt: str) -> 'Temporal *': temp_converted = _ffi.cast('const Temporal *', temp) txt_converted = cstring2text(txt) diff --git a/pymeos_cffi/test.py b/pymeos_cffi/test.py index 764d8093..0f2c6d35 100644 --- a/pymeos_cffi/test.py +++ b/pymeos_cffi/test.py @@ -1,31 +1,12 @@ -from time import time - -from spans import intrange, floatrange - -from pymeos_cffi import tgeompoint_in, meos_initialize, tpoint_out, tintinst_make, tint_in, temporal_merge, \ - temporal_merge_array, intrange_to_intspan, span_out, floatrange_to_floatspan +from pymeos_cffi import * meos_initialize('UTC') -t1 = tint_in('1@2000-01-01') -t2 = tint_in('2@2000-01-02') -ta = [t1, t2] -times = 1000 -s = time() -for _ in range(times): - t3 = temporal_merge(t1, t2) -m = time() -for _ in range(times): - t3 = temporal_merge_array(ta, 2) -e = time() - -print(f'Merge time: {m - s}s') -print(f'Merge Array time: {e - m}s') +t = tfloat_in('2.0@2000-01-01') -ir = intrange(1, 4, lower_inc=False, upper_inc=True) -print(ir, ir.lower_inc, ir.upper_inc) -print(span_out(intrange_to_intspan(ir), -1)) +try: + print(tfloat_out(t, -2)) +except MeosInvalidArgValueError as e: + print(e) -fr = floatrange(1.0, 4.0, lower_inc=False, upper_inc=True) -print(fr, fr.lower_inc, fr.upper_inc) -print(span_out(floatrange_to_floatspan(fr), -1)) +print(tfloat_out(t, 2)) \ No newline at end of file From 4e4f0906cb7f972b0960c239e8fbd3280de57e91 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Mon, 4 Sep 2023 17:00:44 +0200 Subject: [PATCH 5/6] Raise MeosException when error code is unknown --- pymeos_cffi/pymeos_cffi/errors.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pymeos_cffi/pymeos_cffi/errors.py b/pymeos_cffi/pymeos_cffi/errors.py index e186e682..8c947f44 100644 --- a/pymeos_cffi/pymeos_cffi/errors.py +++ b/pymeos_cffi/pymeos_cffi/errors.py @@ -31,7 +31,7 @@ class MeosException(Exception): """Base class for all MEOS errors.""" def __init__(self, code: int, message: str): - super().__init__(message) + super().__init__(f'{message}\nThe MEOS error code ({code}) has not been recognized.') self.code = code @@ -179,3 +179,5 @@ def raise_meos_exception(level: int, code: int, message: str): raise MeosGeoJsonInputError(code, message) elif code == MEOSCode.MEOS_ERR_GEOJSON_OUTPUT: raise MeosGeoJsonOutputError(code, message) + else: + raise MeosException(code, message) From b778aa5593cfde40067aee3cefb17297be3e77c1 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Mon, 4 Sep 2023 17:01:20 +0200 Subject: [PATCH 6/6] Raise MeosException when error code is unknown --- pymeos_cffi/pymeos_cffi/errors.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pymeos_cffi/pymeos_cffi/errors.py b/pymeos_cffi/pymeos_cffi/errors.py index 8c947f44..8d2fd78e 100644 --- a/pymeos_cffi/pymeos_cffi/errors.py +++ b/pymeos_cffi/pymeos_cffi/errors.py @@ -31,7 +31,8 @@ class MeosException(Exception): """Base class for all MEOS errors.""" def __init__(self, code: int, message: str): - super().__init__(f'{message}\nThe MEOS error code ({code}) has not been recognized.') + super().__init__(f'{message}\nThe MEOS error code ({code}) has not been recognized. ' + f'Please, report this to the MEOS developers.') self.code = code