Package types.boxes

Class TBox

java.lang.Object
types.boxes.TBox
All Implemented Interfaces:
Box, TemporalObject

public class TBox extends Object implements Box
Class for representing numeric temporal boxes. Both numeric and temporal bounds may be inclusive or not.
     ``TBox`` objects can be created with a single argument of type string as in MobilityDB.

         >>> 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
     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)
         >>> TBox(xmin='0', xmax='10', tmin=parse('2020-06-01'), tmax=parse('2020-06-0'))
Note that you can create a TBox with only the numerical or the temporal dimension. In these cases, it will be equivalent to a tstzset (if it only has temporal dimension) or to a floatrange (if it only has the numeric dimension).
Author:
ARIJIT SAMAL
  • Field Details

    • xmin_inc

      private boolean xmin_inc
    • xmax_inc

      private boolean xmax_inc
    • tmin_inc

      private boolean tmin_inc
    • tmax_inc

      private boolean tmax_inc
    • _inner

      private jnr.ffi.Pointer _inner
  • Constructor Details

    • TBox

      public TBox()
      ------------------------- Constructors ----------------------------------
    • TBox

      public TBox(jnr.ffi.Pointer inner)
    • TBox

      public TBox(jnr.ffi.Pointer inner, boolean xmin_inc, boolean xmax_inc, boolean tmax_inc, boolean tmin_inc)
    • TBox

      public TBox(String value)
      The string constructor
      Parameters:
      value - - the string with the TBox value
    • TBox

      public TBox(Number xmin, Number xmax)
      Constructor with number parameters
      Parameters:
      xmin - X minimal coordinates
      xmax - X maximal coordinates
    • TBox

      public TBox(Number xmin, Number xmax, LocalDateTime tmin, LocalDateTime tmax)
      Constructor with number and temporal parameters
      Parameters:
      xmin - X minimal coordinates
      xmax - X maximal coordinates
      tmin - temporal minimal value
      tmax - temporal maximal value
    • TBox

      public TBox(Number xmin, Number xmax, LocalDateTime tmin, LocalDateTime tmax, boolean xmin_inc, boolean xmax_inc, boolean tmin_inc, boolean tmax_inc)
      Constructor with number, temporal and inclusions parameters
      Parameters:
      xmin - X minimal coordinates
      xmax - X maximal coordinates
      tmin - temporal minimal value
      tmax - temporal maximal value
      xmin_inc - x minimal inclusion
      xmax_inc - x maximal inclusion
      tmin_inc - temporal minimal inclusion
      tmax_inc - temporal maxmimal inclusion
  • Method Details

    • copy

      public TBox copy()
      Returns a copy of "this".

      MEOS Functions:

    • tbox_copy
    • Returns:
      a new TBox instance
    • from_hexwkb

      public static TBox from_hexwkb(String hexwkb)
      Returns a "TBox" from its WKB representation in hex-encoded ASCII.

      MEOS Functions:

    • tbox_from_hexwkb
    • Parameters:
      hexwkb - WKB representation in hex-encoded ASCII
      Returns:
      a new TBox instance
    • from_value_number

      public static TBox from_value_number(Number value)
    • from_value_span

      public static TBox from_value_span(Span span)
      Returns a "TBox" from a numeric value or span. The created "TBox" will only have a numerical dimension.

      MEOS Functions:

    • int_to_tbox
    • float_to_tbox
    • span_to_tbox
    • span_to_tbox
    • Parameters:
      span - value to be canverted into a TBox
      Returns:
      A new TBox instance
    • from_time

      public static TBox from_time(Time time) throws Exception
      Returns a "TBox" from a Time class. The created "TBox" will only have a temporal dimension.

      MEOS Functions:

      • timestamp_to_tbox
      • timestampset_to_tbox
      • period_to_tbox
      • periodset_to_tbox
      Parameters:
      time - value to be canverted into a TBox
      Returns:
      a TBox instance
      Throws:
      Exception
    • from_value_time

      public static TBox from_value_time(Object value, Object time)
      Returns a "TBox" from a numerical and a temporal object.

      MEOS Functions:

    • int_timestamp_to_tbox
    • int_period_to_tbox
    • float_timestamp_to_tbox
    • float_period_to_tbox
    • span_timestamp_to_tbox
    • span_period_to_tbox
    • Parameters:
      value - numerical span of the TBox
      time - temporal span of the TBox
      Returns:
      A new TBox instance
    • from_tnumber

      public static TBox from_tnumber(TNumber temporal)
      Returns a "TBox" from a TNumber object.

      MEOS Functions:

    • tnumber_to_tbox
    • Parameters:
      temporal - temporal number to be canverted into a TBox
      Returns:
      A new TBox instance
    • toString

      public String toString()
      Returns a string representation of "this".

      MEOS Functions:

    • tbox_out
    • Overrides:
      toString in class Object
      Returns:
      a String instance
    • toString

      public String toString(int max_decimals)
      Returns a string representation of "this".

      MEOS Functions:

    • tbox_out
    • Parameters:
      max_decimals - number of maximal decimals
      Returns:
      a String instance
    • to_floatspan

      public FloatSpan to_floatspan()
      Returns the numeric span of "this".

      MEOS Functions:

    • tbox_to_floatspan
    • Returns:
      A new FloatSpan instance
    • to_period

      public tstzspan to_period()
      Returns the temporal span of "this".

      MEOS Functions:

    • tbox_to_period
    • Specified by:
      to_period in interface Box
      Returns:
      a tstzset instance
    • has_x

      public boolean has_x()
      Returns whether "this" has a numeric dimension.

      MEOS Functions:

    • tbox_hasx
    • Returns:
      True if "this" has a numeric dimension, False otherwise
    • has_t

      public boolean has_t()
      Returns whether "this" has a temporal dimension.

      MEOS Functions:

    • tbox_hast
    • Returns:
      True if "this" has a temporal dimension, False otherwise
    • expand

      public TBox expand(Object obj)
      Returns the result of expanding "this" with the "other". Depending on the type of "other", the expansion will be of the numeric dimension (Float) or both (TBox).

      MEOS Functions:

    • tbox_copy
    • tbox_expand
    • tbox_expand_value
    • tbox_expand_time
    • Parameters:
      obj - object used to expand "this"
      Returns:
      a TBox instance
    • round

      public TBox round()
      Returns "this" rounded to the given number of decimal digits.

      MEOS Functions:

    • tbox_round
    • Returns:
      a instance
    • round

      public TBox round(int maxdd)
      Returns "this" rounded to the given number of decimal digits.

      MEOS Functions:

    • tbox_round
    • Parameters:
      maxdd - maximum number of decimal digits
      Returns:
      a instance
    • is_adjacent_tbox

      public boolean is_adjacent_tbox(Object other)
      Returns whether "this" is adjacent to "other". That is, they share only the temporal or numerical bound and only one of them contains it.
               Examples:
                   >>> 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('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('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
      
       

      MEOS Functions:

    • adjacent_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - object to compare with
      Returns:
      true if adjacent, false otherwise
    • is_contained_in

      public boolean is_contained_in(Object other)
      Returns whether "this" is contained in "other".
               Examples:
                   >>> 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('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('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
       

      MEOS Functions:

    • contained_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if contained, false otherwise
    • contains

      public boolean contains(Object other)
      Returns whether "this" temporally contains "other".
               Examples:
                   >>> 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('TBoxFloat XT([1, 2], [2012-01-01, 2012-01-02]').contains(TBox('TBoxFloat XT((1, 2), (2012-01-01, 2012-01-02)'))
                   >>> True
                   >>> TBox('TBoxFloat XT((1, 2), (2012-01-01, 2012-01-02)').contains(TBox('TBoxFloat XT([1, 2], [2012-01-01, 2012-01-02]'))
                   >>> False
       

      MEOS Functions:

    • contains_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if contains, false otherwise
    • overlaps

      public boolean overlaps(Object other)
      Returns whether "this" overlaps "other". That is, both share at least an instant or a value.

      MEOS Functions:

    • overlaps_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if overlaps, false otherwise
    • is_same

      public boolean is_same(Object other)
      Returns whether "this" is the same as "other".

      MEOS Functions:

    • same_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if same, false otherwise
    • is_left

      public boolean is_left(Object other)
      Returns whether "this" is strictly to the left of "other".

      MEOS Functions:

    • left_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      True if left, False otherwise
    • is_over_or_left

      public boolean is_over_or_left(Object other)
      Returns whether "this" is to the left of "other" allowing overlap. That is, "this" does not extend to the right of "other".

      MEOS Functions:

    • overleft_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if overleft, false otherwise
    • is_right

      public boolean is_right(Object other)
      Returns whether "this" is strictly to the right of "other".

      MEOS Functions:

    • right_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if right, false otherwise
    • is_over_or_right

      public boolean is_over_or_right(Object other)
      Returns whether "this" is to the right of "other" allowing overlap. That is, "this" does not extend to the left of "other".

      MEOS Functions:

    • overright_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      True if overright, False otherwise
    • is_before

      public boolean is_before(Object other)
      Returns whether "this" is strictly before "other".

      MEOS Functions:

    • before_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if before, false otherwise
    • is_over_or_before

      public boolean is_over_or_before(Object other)
      Returns whether "this" is before "other" allowing overlap. That is, "this" does not extend after "other".

      MEOS Functions:

    • overbefore_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if overbefore, false otherwise
    • is_after

      public boolean is_after(Object other)
      Returns whether "this" is strictly after "other".

      MEOS Functions:

    • after_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if after, false otherwise
    • is_over_or_after

      public boolean is_over_or_after(Object other)
      Returns whether "this" is after "other" allowing overlap. That is, "this" does not extend before "other".

      MEOS Functions:

    • overafter_tbox_tbox
    • tnumber_to_tbox
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if overafter, false otherwise
    • union

      public TBox union(TBox other, boolean strict)
      Returns the union of "this" with "other". Fails if the union is not contiguous.

      MEOS Functions:

    • union_tbox_tbox
    • Parameters:
      other - temporal object to merge with
      Returns:
      a TBox instance
    • add

      public TBox add(TBox other, boolean strict)
      Returns the union of "this" with "other". Fails if the union is not contiguous.

      MEOS Functions:

    • union_tbox_tbox
    • Parameters:
      other - temporal object to merge with
      Returns:
      a TBox instance
    • intersection

      public TBox intersection(TBox other)
      Returns the intersection of "this" with "other".

      MEOS Functions:

    • intersection_tbox_tbox
    • Parameters:
      other - temporal object to merge with
      Returns:
      a TBox instance if the instersection is not empty, "null" otherwise.
    • mul

      public TBox mul(TBox other)
      Returns the intersection of "this" with "other".

      MEOS Functions:

    • intersection_tbox_tbox
    • Parameters:
      other - temporal object to merge with
      Returns:
      a TBox instance if the instersection is not empty, "null" otherwise.
    • is_float

      public boolean is_float()
      Returns the distance between the nearest points of "this" and "other".

      MEOS Functions:

    • nad_tbox_tbox
    • Returns:
      A Float with the distance between the nearest points of "this" and "other".
    • nearest_approach_distance

      public float nearest_approach_distance(Object other)
    • eq

      public boolean eq(Box other)
      Returns whether "this" is equal to "other".

      MEOS Functions:

    • tbox_eq
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if equal, false otherwise
    • notEquals

      public boolean notEquals(Box other)
      Returns whether "this" is not equal to "other".

      MEOS Functions:

    • tbox_ne
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if not equal, false otherwise
    • lessThan

      public boolean lessThan(Box other) throws Exception
      Returns whether "this" is less than "other". The time dimension is compared first, then the space dimension.

      MEOS Functions:

    • tbox_lt
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if less than, false otherwise
      Throws:
      Exception
    • lessThanOrEqual

      public boolean lessThanOrEqual(Box other) throws Exception
      Returns whether "this" is less than or equal to "other". The time dimension is compared first, then the space dimension.

      MEOS Functions:

    • tbox_le
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if less than or equal to, false otherwise
      Throws:
      Exception
    • greaterThan

      public boolean greaterThan(Box other) throws Exception
      Returns whether "this" is greater than "other". The time dimension is compared first, then the space dimension.

      MEOS Functions:

    • tbox_gt
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if greater than, false otherwise
      Throws:
      Exception
    • greaterThanOrEqual

      public boolean greaterThanOrEqual(Box other) throws Exception
      Returns whether "this" is greater than or equal to "other". The time dimension is compared first, then the space dimension.

      MEOS Functions:

    • tbox_ge
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if greater than or equal to, false otherwise
      Throws:
      Exception
    • get_tmin_inc

      public boolean get_tmin_inc()
    • get_tmax_inc

      public boolean get_tmax_inc()
    • get_inner

      public jnr.ffi.Pointer get_inner()