Sélection (path consistency algorithm )
Timeslice queries#
Our focus on this section concern the selection queries with, in particular the query type over intervals spatial or temporal. Given a query interval q = [q.st, q.end], the objective is to find the ids of all objects s app S, whose intervals overlap with q, i.e. they satisfy a generalized OVERLAPS relationship. In addition, we study the retrieval of data intervals that satisfy one of Allen’s interval algebra relationships with q.
Stabbing queries are a special class of selection queries for which q.st = q.end and the predicate is CONTAINED_BY.
Overall picture of selection process : selection is performed by a selector object, containing an arbitrary number of constraints, combined by OR, AND or XOR operator. Since only a single operator is allowed in the selector, a “global selector” is provided to the users to combine the output of several individual selectors. Again, the output may be combined with OR, AND or XOR.
For example, given two circles C1 and C2, and two rectangles R1 and R2, to select tracks crossing either C1 or C2, and either R1 or R2, we would like to write the following combination of constraints : F = (C1 + C2).(R1 + R2), where + and . operators denote OR and AND respectively. Such a constraint requires two different combination rules, and therefore cannot be expressed with a single selector. A solution is to create two disjonctive (OR) type selectors S1 and S2 with S1 = C1 + C2 and S2 = R1 + R2. Then S1 and S2 are combined in a conjunctive (AND) type global selector. Note that boolean algebraic rules show that it is possible as well to combine 4 conjunctive- type selectors (C1.R1, C1.R2, C2.R1 and C2.R2) in a disjunctive-type global selector. Constraints may be based on:
a geometrical shape (Rectangle, circle or polygon in Geometrics). This is the standard type of constraint. Different modes are:
MODE_CROSSES: tracks crossing shape interior/boundary are selected
MODE_INSIDE : tracks remaining fully inside the shape are selected
MODE_GETS_IN: tracks getting in (at least once) shape are selected
MODE_INSIDE : tracks getting out (at least once) shape are selected
a track t as a reference. Available modes are:
MODE_CROSSES : tracks intersecting t (at least once) are selected
MODE_PARALLEL: tracks following t are selected
a “toll gate” segment, defined by two Coords objects: tracks crossing (at least once) the toll gate are selected
All these constraint may be provided with an additional time constraint, specifying the time interval (between two GPSTime dates) where crossing / containing / getting in / getting out… operations are tested. Besides, there are two types of selection:
TYPE_SELECT: tracks abiding by constraints are returned as they are
TYPE_CUT_AND_SELECT: tracks abiding by constraints are cut and returned
General constraint syntax:
Declaration of a TimeConstraint t1 = TimeConstraint(initial_date, final_date, options)
Add comment here c1 = Constraint(shape, t1, options) c2 = TrackConstraint(track, t2, options) c3 = TollGateConstraint(shape, t3, options)
Add comment here s1 = Selector(c1, c2, …, options) s2 = Selector(c3, c4, …, options)
Add comment here selector = GlobalSelector([s1, s2, …], options)
Import de la librairie tracklib#
[1]:
import matplotlib.pyplot as plt
import os
import sys
#-------------------------------------------------------
# Import de tracklib
module_path = os.path.abspath(os.path.join('../../..'))
if module_path not in sys.path:
sys.path.append(module_path)
[2]:
from tracklib.core.ObsCoords import ENUCoords
import tracklib.algo.Geometrics as Geometrics
from tracklib.algo.Selection import Constraint
from tracklib.algo.Selection import TYPE_CUT_AND_SELECT, MODE_INSIDE
from tracklib.algo.Selection import Selector
Xmin = 29.72
Xmax = 29.77
Ymin = 62.585
Ymax = 62.615
ll = ENUCoords(Xmin, Ymin)
ur = ENUCoords(Xmax, Ymax)
bbox = Geometrics.Rectangle(ll, ur)
constraintBBox = Constraint(shape = bbox, mode = MODE_INSIDE, type=TYPE_CUT_AND_SELECT)
s = Selector([constraintBBox])
print (s)
Conjunctive selector with following constraint(s):
(1) Rectangle-shaped selecting constraint (mode 'INSIDE') with temporal constraint: