Class Temporal<V extends Serializable>

java.lang.Object
types.temporal.Temporal<V>
Type Parameters:
V - - Base type of the temporal data type eg. Integer, Boolean
All Implemented Interfaces:
Serializable, TemporalObject
Direct Known Subclasses:
TInstant, TSequence, TSequenceSet

public abstract class Temporal<V extends Serializable> extends Object implements Serializable, TemporalObject
Abstract class for Temporal sub types
Author:
ARIJIT SAMAL
See Also:
  • Field Details

    • inner

      private jnr.ffi.Pointer inner
  • Constructor Details

    • Temporal

      public Temporal()
      ------------------------- Constructors ----------------------------------------
    • Temporal

      public Temporal(String str)
    • Temporal

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

      public Temporal(String customType, TemporalType temporalType)
  • Method Details

    • createStringInner

      public abstract jnr.ffi.Pointer createStringInner(String str)
    • createInner

      public abstract jnr.ffi.Pointer createInner(jnr.ffi.Pointer inner)
    • getCustomType

      public abstract String getCustomType()
    • getTemporalType

      public abstract TemporalType getTemporalType()
    • _factory

      public static Temporal _factory(jnr.ffi.Pointer inner, String customType, TemporalType temporalType)
    • copy

      public Temporal copy()
      Returns a copy of the temporal object.
      Returns:
      a copy of the object
    • from_hexwkb

      public Temporal from_hexwkb(String str)
      Returns a temporal object from a hex-encoded WKB string.

      MEOS Functions:

    • temporal_from_hexwkb
    • Parameters:
      str - The hex-encoded WKB string.
      Returns:
      A temporal object from a hex-encoded WKB string.
    • from_wkb

      public Temporal from_wkb(jnr.ffi.Pointer wkb, long size)
      Returns a temporal object from WKB bytes. Args: wkb: The WKB string. Returns: A temporal object from WKB bytes. MEOS Functions: temporal_from_wkb
    • as_hexwkb

      public String as_hexwkb(jnr.ffi.Pointer wkb, long size)
      Returns the temporal object as a hex-encoded WKB string. Returns: The temporal object as a hex-encoded WKB string. MEOS Functions: temporal_as_hexwkb
    • as_wkb

      public jnr.ffi.Pointer as_wkb()
      Returns the temporal object as a hex-encoded WKB string. Returns: The temporal object as a hex-encoded WKB string. MEOS Functions: temporal_as_wkb
    • as_mfjson

      public String as_mfjson(boolean with_bbox, int flags, int precision, String srs)
      Returns the temporal object as a MF-JSON string.

      MEOS Functions:

    • temporal_as_mfjson
    • Parameters:
      with_bbox - Whether to include the bounding box in the output.
      flags - The flags to use for the output.
      precision - The precision to use for the output.
      srs - The SRS to use for the output.
      Returns:
      The temporal object as a MF-JSON string.
    • as_mfjson

      public String as_mfjson()
      Returns the temporal object as a MF-JSON string.

      MEOS Functions:

    • temporal_as_mfjson
    • Returns:
      The temporal object as a MF-JSON string.
    • from_merge

      public Temporal from_merge(jnr.ffi.Pointer temporals)
      Returns a temporal object that is the result of merging the given temporal objects. Args: temporals: The temporal objects to merge. Returns: A temporal object that is the result of merging the given temporal objects. MEOS Functions: temporal_merge_array
    • from_merge_array

      public Temporal from_merge_array(List<Temporal> temporals)
      Returns a temporal object that is the result of merging the given temporal objects. Args: temporals: The temporal objects to merge. Returns: A temporal object that is the result of merging the given temporal objects.
    • getInner

      public jnr.ffi.Pointer getInner()
      ------------------------- Accessors ----------------------------------------
    • bounding_box

      public tstzspan bounding_box()
      Returns the bounding box of "this".

      MEOS Functions:

    • temporal_to_period
    • Returns:
      The bounding box of `self`.
    • time

      public tstzspanset time()
      Returns the tstzspanset on which `self` is defined. MEOS Functions: temporal_time
      Returns:
      the tstzspanset on which `self` is defined.
    • interpolation

      public TInterpolation interpolation()
    • period

      public tstzspan period()
      Returns the tstzset on which "this" is defined ignoring potential time gaps.

      MEOS Functions:

    • temporal_to_period
    • Returns:
    • timespan

      public tstzspan timespan()
      Returns the tstzspan on which "this" is defined ignoring potential time gaps.

      MEOS Functions:

    • temporal_to_period
    • Returns:
    • num_instants

      public int num_instants()
      Returns the number of instants in "this". MEOS Functions: temporal_num_instants
      Returns:
      Returns the number of instants in "this".
    • start_instant

      public Temporal start_instant()
      Returns the first instant in "this".

      MEOS Functions:

    • temporal_start_instant
    • Returns:
      Returns the first instant in "this".
    • end_instant

      public Temporal end_instant()
      Returns the last instant in "this".

      MEOS Functions:

    • temporal_end_instant
    • Returns:
      Returns the last instant in "this".
    • min_instant

      public Temporal min_instant()
      Returns the instant in "this" with the minimum value. If multiple instants have the minimum value, the first one is returned.

      MEOS Functions:

    • temporal_min_instant
    • Returns:
      Returns the instant in "this" with the minimum value.
    • max_instant

      public Temporal max_instant()
      Returns the instant in "this" with the maximum value. If multiple instants have the maximum value, the first one is returned.

      MEOS Functions:

    • temporal_max_instant
    • Returns:
      Returns the instant in "this" with the maximum value.
    • instant_n

      public Temporal instant_n(int n)
      Returns the n-th instant in "this". (0-based)

      MEOS Functions:

    • temporal_instant_n
    • Parameters:
      n - instant
      Returns:
      a new Temporal
    • duration

      public Duration duration(boolean ignore_gaps)
    • tstzspan

      public tstzspan tstzspan()
    • num_timestamps

      public int num_timestamps()
      Returns the number of timestamps in "this".

      MEOS Functions:

    • temporal_num_timestamps
    • Returns:
      Returns the number of timestamps in "this".
    • start_timestamp

      public LocalDateTime start_timestamp()
      Returns the first timestamp in "this".

      MEOS Functions:

    • temporal_start_timestamps
    • Returns:
      Returns the first timestamp in "this".
    • end_timestamp

      public LocalDateTime end_timestamp()
      Returns the last timestamp in "this".

      MEOS Functions:

    • temporal_end_timestamps
    • Returns:
      Returns the last timestamp in "this".
    • timestampToLocalDateTime

      public static LocalDateTime timestampToLocalDateTime(int timestamp)
    • timestamp_n

      public LocalDateTime timestamp_n(int n)
    • timestamps

      public List<LocalDateTime> timestamps()
      Returns the timestamps in `self`. MEOS Functions: temporal_timestamps
    • instants

      public List<Temporal> instants()
      Returns the instants in `self`. MEOS Functions: temporal_instants
    • values

      public List<Temporal> values()
      Returns the list of values taken by `self`.
    • segments

      public List<Temporal> segments()
      Returns the temporal segments in `self`. MEOS Functions: temporal_segments
    • hash

      public long hash()
      Returns the hash of the temporal object.

      MEOS Functions:

    • temporal_hash
    • Returns:
      The hash of the temporal object.
    • set_interpolation

      public Temporal set_interpolation(TInterpolation interpolation)
      Returns a new Temporal object equal to "this" with the given interpolation. MEOS Functions:
    • temporal_set_interpolation
    • Parameters:
      interpolation - int value
      Returns:
      Returns a new Temporal object equal to "this" with the given * interpolation.
    • shift_time

      public Temporal shift_time(Duration duration)
      Returns a new :class:`Temporal` with the temporal dimension shifted by ``delta``. Args: delta: :class:`datetime.timedelta` instance to shift MEOS Functions: temporal_shift_time
    • scale_time

      public Temporal scale_time(Duration duration)
      Returns a new :class:`Temporal` scaled so the temporal dimension has duration ``duration``. Args: duration: :class:`datetime.timedelta` instance representing the duration of the new temporal MEOS Functions: temporal_scale_time
    • shift_scale_time

      public Temporal shift_scale_time(Duration shift, Duration scale)
      Returns a new :class:`Temporal` with the time dimension shifted by ``shift`` and scaled so the temporal dimension has duration ``duration``. Args: shift: :class:`datetime.timedelta` instance to shift duration: :class:`datetime.timedelta` instance representing the duration of the new temporal MEOS Functions: temporal_shift_scale_time
    • temporal_sample

      public Temporal temporal_sample(Object duration, Object start, TInterpolation interpolation)
      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 used by default is Monday, January 3, 2000. interpolation: Interpolation of the resulting temporal object. If None, defaults to the interpolation of ``self``. MEOS Functions: temporal_tsample
    • temporal_precision

      public Temporal temporal_precision(Object duration, Object start)
      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 used by default is Monday, January 3, 2000. MEOS Functions: temporal_tprecision
    • to_instant

      public Temporal to_instant()
      Returns "this" as a TInstant.

      MEOS Functions:

    • temporal_to_tinstant
    • Returns:
      Returns "this" as a TInstant.
    • to_sequence

      public Temporal to_sequence(TInterpolation interpolation)
      Converts "this" into a TSequence.

      MEOS Functions:

    • temporal_to_sequence
    • Parameters:
      interpolation - int value
      Returns:
      a new TSequence.
    • to_sequenceset

      public Temporal to_sequenceset(TInterpolation interpolation)
      Returns "this" as a new TSequenceSet. MEOS Functions:
    • temporal_to_tsequenceset
    • Parameters:
      interpolation - int value
      Returns:
      a new TSequenceSet
    • toDataFrame

      public List<Map<String,Object>> toDataFrame()
    • append_instant

      public Temporal append_instant(TInstant instant, float max_dist, Duration max_time)
      Returns a new :class:`Temporal` object equal to `self` with `instant` appended. Args: instant: :class:`TInstant` to append max_dist: Maximum distance for defining a gap max_time: Maximum time for defining a gap MEOS Functions: temporal_append_tinstant
    • append_sequence

      public Temporal append_sequence(TSequence sequence)
      Returns a new Temporal object equal to "this" with "sequence" appended.

      MEOS Functions:

    • temporal_append_tsequence
    • Parameters:
      sequence - sequence: a TSequence to append
      Returns:
      a new Temporal object
    • insert

      public Temporal insert(Temporal other)
      Returns a new Temporal object equal to "this" with "other" inserted.

      MEOS Functions:

    • temporal_insert
    • Parameters:
      other - Temporal object to insert in "this"
      Returns:
      Returns a new Temporal object equal to "this" with "other" * inserted.
    • createPointerArray

      private jnr.ffi.Pointer createPointerArray(List<?> temporalList) throws Exception
      Throws:
      Exception
    • merge

      public Temporal merge(Object other) throws Exception
      Returns a new :class:`Temporal` object that is the result of merging `self` with `other`. MEOS Functions: temporal_merge, temporal_merge_array
      Throws:
      Exception
    • insert

      public Temporal insert(Temporal other, boolean connect)
      Returns a new Temporal object equal to "this" with "other" inserted.

      MEOS Functions:

    • temporal_insert
    • Parameters:
      other - Temporal object to insert in "this"
      connect - wether to connect the inserted elements with the existing * elements.
      Returns:
      Returns a new Temporal object equal to "this" with "other" * inserted.
    • update

      public Temporal update(Temporal other)
      Returns a new Temporal object equal to "this" updated with "other".

      MEOS Functions:

    • temporal_update
    • Parameters:
      other - Temporal object to update "this" with
      Returns:
      Returns a new Temporal object equal to "this" updated with * "other".
    • update

      public Temporal update(Temporal other, boolean connect)
      Returns a new Temporal object equal to "this" updated with "other".

      MEOS Functions:

    • temporal_update
    • Parameters:
      other - Temporal object to update "this" with
      connect - wether to connect the updated elements with the * existing elements.
      Returns:
      Returns a new Temporal object equal to "this" updated with * "other".
    • delete

      public Temporal delete(Object other, Boolean connect) throws Exception
      Returns a new :class:`Temporal` object equal to `self` with elements at `other` removed. Args: other: :class:`Time` object to remove from `self` connect: whether to connect the potential gaps generated by the deletions. MEOS Functions: temporal_update
      Throws:
      Exception
    • at

      public Temporal at(Time other)
      Returns a new temporal object with the values of "this" restricted to the time "other".

      MEOS Functions:

      • temporal_at_timestamp
      • temporal_at_timestampset
      • temporal_at_period
      • temporal_at_periodset
      Parameters:
      other - A time object to restrict the values of "this" to.
      Returns:
      A new temporal object of the same subtype as `self`
    • at_min

      public Temporal at_min()
      Returns a new temporal object containing the times "this" is at its minimum value.

      MEOS Functions:

    • temporal_at_min
    • Returns:
      A new temporal object of the same subtype as `self`.
    • at_max

      public Temporal at_max()
      Returns a new temporal object containing the times "this" is at its maximum value.

      MEOS Functions:

    • temporal_at_max
    • Returns:
      A new temporal object of the same subtype as `self`.
    • minus

      public Temporal minus(Time other)
      Returns a new temporal object with the values of "this" removing those happening at "other".

      MEOS Functions:

      • temporal_minus_timestamp
      • temporal_minus_timestampset
      • temporal_minus_period
      • temporal_minus_periodset
      Parameters:
      other - A time object to remove from "this".
      Returns:
      A new temporal object of the same subtype as "this".
    • minus_min

      public Temporal minus_min()
      Returns a new temporal object containing the times "this" is not at its minimum value.

      MEOS Functions:

    • temporal_minus_min
    • Returns:
      A new temporal object of the same subtype as "this".
    • minus_max

      public Temporal minus_max()
      Returns a new temporal object containing the times "this" is not at its maximum value.

      MEOS Functions:

    • temporal_minus_max
    • Returns:
      A new temporal object of the same subtype as "this".
    • is_adjacent

      public boolean is_adjacent(TemporalObject other) throws Exception
      Returns whether the bounding box of "this" is adjacent to the bounding box of "other". Temporal subclasses may override this method to provide more specific behavior related to their types a check adjacency over more dimensions.

      See Also: Set.is_adjacent(Base)

      Parameters:
      other - A time or temporal object to compare to "this".
      Returns:
      True if adjacent, False otherwise.
      Throws:
      Exception
    • is_temporally_adjacent

      public boolean is_temporally_adjacent(TemporalObject other) throws Exception
      Returns whether the bounding period of "this" is temporally adjacent to the bounding period of "other".

      See Also: tstzset.is_adjacent(TemporalObject)

      Parameters:
      other - A time or temporal object to compare to "this".
      Returns:
      True if adjacent, False otherwise.
      Throws:
      Exception
    • is_contained_in

      public boolean is_contained_in(TemporalObject other) throws Exception
      Returns whether the bounding period of "this "is contained in the bounding period of "other". Temporal subclasses may override this method to provide more specific behavior related to their types

      See Also: tstzset.is_contained_in(TemporalObject)

      Parameters:
      other - A time or temporal object to compare to "this".
      Returns:
      True if contained, False otherwise.
      Throws:
      Exception
    • is_temporally_contained_in

      public boolean is_temporally_contained_in(TemporalObject other) throws Exception
      Returns whether the bounding period of "this" is contained in the bounding period of "other".

      See Also: tstzset.is_contained_in(TemporalObject)

      Parameters:
      other - A time or temporal object to compare to "this".
      Returns:
      True if contained, False otherwise.
      Throws:
      Exception
    • contains

      public boolean contains(TemporalObject other) throws Exception
      Returns whether the bounding period of "this" contains the bounding period of "other". Temporal subclasses may override this method to provide more specific behavior related to their types

      See Also: tstzset.contains(TemporalObject)

      Parameters:
      other - A time or temporal object to compare to "this".
      Returns:
      True if contains, False otherwise.
      Throws:
      Exception
    • temporally_contains

      public boolean temporally_contains(TemporalObject other) throws Exception
      Returns whether the bounding period of "this" contains the bounding period of "other".

      See Also: tstzset.contains(TemporalObject)

      Parameters:
      other - A time or temporal object to compare to "this".
      Returns:
      True if contains, False otherwise.
      Throws:
      Exception
    • overlaps

      public boolean overlaps(TemporalObject other) throws Exception
      Returns whether the bounding period of "this" overlaps the bounding period of "other". Temporal subclasses may override this method to provide more specific behavior related to their types

      See Also: tstzset.overlaps(TemporalObject)

      Parameters:
      other - A time or temporal object to compare to "this".
      Returns:
      True if overlaps, False otherwise.
      Throws:
      Exception
    • temporally_overlaps

      public boolean temporally_overlaps(TemporalObject other) throws Exception
      Returns whether the bounding period of "this" overlaps the bounding period of "other".

      See Also: tstzset.overlaps(TemporalObject)

      Parameters:
      other - A time or temporal object to compare to "this".
      Returns:
      True if overlaps, False otherwise.
      Throws:
      Exception
    • is_same

      public boolean is_same(TemporalObject other) throws Exception
      Returns whether the bounding period of "this" is the same as the bounding period of "other". Temporal subclasses may override this method to provide more specific behavior related to their types

      See Also: tstzset.is_same(Time) (TemporalObject)}

      Parameters:
      other - A time or temporal object to compare to `self`.
      Returns:
      True if same, False otherwise.
      Throws:
      Exception
    • is_before

      public boolean is_before(TemporalObject other) throws Exception
      Returns whether "this" is before "other".

      See Also: tstzset.is_before(TemporalObject)

      Parameters:
      other - A time or temporal object to compare "this" to.
      Returns:
      True if "this" is before "other", False otherwise.
      Throws:
      Exception
    • is_over_or_before

      public boolean is_over_or_before(TemporalObject other) throws Exception
      Returns whether "this" is before "other" allowing overlap. That is, "this" doesn't extend after "other".

      See Also: tstzset.is_over_or_before(TemporalObject)

      Parameters:
      other - A time or temporal object to compare `self` to.
      Returns:
      True if `self` is before `other` allowing overlap, False otherwise.
      Throws:
      Exception
    • is_after

      public boolean is_after(TemporalObject other) throws Exception
      Returns whether "this" is after "other".

      See Also: tstzset.is_after(TemporalObject)

      Parameters:
      other - A time or temporal object to compare "this" to.
      Returns:
      True if "this" is after "other", False otherwise.
      Throws:
      Exception
    • is_over_or_after

      public boolean is_over_or_after(TemporalObject other) throws Exception
      Returns whether "this" is after "other" allowing overlap. That is, "this" doesn't extend before "other".

      See Also: tstzset.is_over_or_after(TemporalObject)

      Parameters:
      other - A time or temporal object to compare "this" to.
      Returns:
      True if "this" is after "other" allowing overlap, False otherwise.
      Throws:
      Exception
    • frechet_distance

      public float frechet_distance(Temporal other)
      Returns the Frechet distance between "this" and "other".

      MEOS Functions:

    • temporal_frechet_distance
    • Parameters:
      other - A temporal object to compare to "this".
      Returns:
      A Float with the Frechet distance.
    • dyntimewarp_distance

      public float dyntimewarp_distance(Temporal other)
      Returns the Dynamic Time Warp distance between "this" and "other".

      MEOS Functions:

    • temporal_dyntimewarp_distance
    • Parameters:
      other - A temporal object to compare to "this".
      Returns:
      A Float with the Dynamic Time Warp distance.
    • hausdorff_distance

      public float hausdorff_distance(Temporal other)
      Returns the Hausdorff distance between "this" and "other".

      MEOS Functions:

    • temporal_hausdorff_distance
    • Parameters:
      other - A temporal object to compare to "this".
      Returns:
      A Float with the Hausdorff distance.
    • temporal_simplify_dp

      public jnr.ffi.Pointer temporal_simplify_dp(jnr.ffi.Pointer temp, double dist, boolean sync)
      Return the simplified trip using Douglas-Peucker algorithm
      Parameters:
      temp - Pointer object
      dist - distance
      sync - synchronization
      Returns:
      a new Pointer object
    • createEmptyPointerArray

      private jnr.ffi.Pointer createEmptyPointerArray(jnr.ffi.Runtime runtime)
      Returns a list of temporal objects of the same subtype as `self` with the same values as `self` but split in temporal tiles of duration `duration` starting at `start`. 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 used by default is Monday, January 3, 2000. Returns: A list of temporal objects of the same subtype as `self`. MEOS Functions: temporal_time_split
    • time_split

      public List<Temporal> time_split(Object duration, Object start)
    • convertToTimestamp

      public static long convertToTimestamp(LocalDateTime dateTime)
      Returns a list of temporal objects of the same subtype as `self` with the same values as `self` but split in n temporal tiles of equal duration. Args: n: An :class:`int` with the number of temporal tiles. Returns: A list of temporal objects of the same subtype as `self`. MEOS Functions: temporal_time_split
    • calculateDifference

      public static Duration calculateDifference(LocalDateTime start, LocalDateTime end)
    • calculateIntermediateDuration

      public static Duration calculateIntermediateDuration(LocalDateTime start, LocalDateTime end, int n)
    • time_split_n

      public List<Temporal> time_split_n(int n)
    • stops

      public Temporal stops(double max_distance, Duration max_duration)
      Return the subsequences where the objects stay within an area with a given maximum size for at least the specified duration. Args: max_distance: A :class:`float` with the maximum distance of a stop. min_duration: A :class:`timedelta` with the minimum duration of a stop. Returns: A :class:`SequenceSet` of the same subtype as `self` with the stops. MEOS Functions: temporal_stops
    • eq

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

      MEOS Functions: temporal_eq

      Parameters:
      other - A temporal object to compare to "this".
      Returns:
      A Boolean with the result of the equality relation.
    • notEquals

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

      MEOS Functions:

    • temporal_ne
    • Parameters:
      other - A temporal object to compare to "this".
      Returns:
      A Boolean with the result of the not equal relation.
    • lessThan

      public boolean lessThan(Temporal other)
      Returns whether "this" is less than "other".

      MEOS Functions:

    • temporal_lt
    • Parameters:
      other - A temporal object to compare to "this".
      Returns:
      A Boolean with the result of the less than relation.
    • lessThanOrEqual

      public boolean lessThanOrEqual(Temporal other)
      Returns whether "this" is less or equal than "other".

      MEOS Functions:

    • temporal_le
    • Parameters:
      other - A temporal object to compare to "this".
      Returns:
      A Boolean with the result of the less or equal than relation.
    • greaterThan

      public boolean greaterThan(Temporal other)
      Returns whether "this" is greater than "other".

      MEOS Functions:

    • temporal_gt
    • Parameters:
      other - A temporal object to compare to "this".
      Returns:
      A Boolean with the result of the greater than relation.
    • greaterThanOrEqual

      public boolean greaterThanOrEqual(Temporal other)
      Returns whether "this" is greater or equal than "other".

      MEOS Functions:

    • temporal_ge
    • Parameters:
      other - A temporal object to compare to "this".
      Returns:
      A Boolean with the result of the greater or equal than * relation.