Coverage report: /development/source/library/org/datagraph/spocq-shard/src/algebra/operators/strbon-allen.lisp

KindCoveredAll%
expression0122 0.0
branch012 0.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 
2
 (:documentation "allen's temporal predicates based on spocq:interval data"
3
  "there are three sorts of temporal data which pertain to bounded sequences of locations
4
  - interval is the open-closed set of timeline locations between two given locations. for this implimentation the resolution is microseconds.
5
  - duration is some quantity of locations, that is microseconds
6
  - period is a length of time which is not exact, for example a year
7
 
8
  This representation expresses the three as spocq:interval, xsd:day-time-duration and xsd:month-year duration.
9
  Allen (https://www.ics.uci.edu/~alspaugh/cls/shr/allen.html) defines thirteen relations
10
  (seven basic with inverses and = being symmetric).
11
  Thi file defines them in terms of spocq:interval data and includes bindings to names
12
  in the strdf namespace.
13
 
14
  An alternative binding is the OQWLTime vocabulary:
15
  (http://www.w3.org/TR/owl-time/)
16
  OWL-Time provides the interval relations:
17
   intervalEquals, intervalBefore, intervalMeets, intervalOverlaps,
18
   intervalStarts, intervalDuring, intervalFinishes,
19
   and their reverse interval relations:
20
   intervalAfter, intervalMetBy, intervalOverlappedBy, intervalStartedBy,
21
   intervalContains, intervalFinishedBy.
22
 strdf::
23
 
24
  The aggregation operators are implemented by defining specializations for +, <, and <= for intervals and providing a
25
  specialization of the boundary case of comparing to 0 in the context of aggregation:
26
  - strdf:intersectAll : Computes the intersection of all periods present each group of the result set. 
27
  - strdf:maxDuration : Computes the maximum duration of the periods in each group. strdf:period
28
  - strdf:maximalPeriod
29
 
30
  the declared namespace for that library:
31
      1 PREFIX lgd:<http://linkedgeodata.org/triplify/>
32
      2 PREFIX lgdgeo:<http://www.w3.org/2003/01/geo/wgs84_pos#>
33
      3 PREFIX lgdont:<http://linkedgeodata.org/ontology/>
34
      4 PREFIX geonames:<http://www.geonames.org/ontology#>
35
      5 PREFIX clc: <http://geo.linkedopendata.gr/corine/ontology#>
36
      6 PREFIX gag: <http://geo.linkedopendata.gr/greekadministrativeregion/ontology#>
37
      7 PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#>
38
      8 PREFIX dlr: <http://www.earthobservatory.eu/ontologies/dlrOntology-v2.owl#>
39
      9 PREFIX strdf: <http://strdf.di.uoa.gr/ontology#>
40
     10 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
41
     11 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
42
     12 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
43
     13 PREFIX geo: <http://www.opengis.net/ont/geosparql#>
44
     14 PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
45
     15 PREFIX ogc: <http://www.opengis.net/def/uom/OGC/1.0/>
46
     16 PREFIX ex: <http://example.org/>
47
     17 PREFIX skos:<http://www.w3.org/2004/02/skos/core#> ")
48
 
49
 (defpackage "http://strdf.di.uoa.gr/ontology#"
50
   ;; http://www.strabon.di.uoa.gr/download.html
51
   (:use )
52
   (:nicknames "strdf")
53
   (:documentation "The strabon interface package")
54
   ;; consistent with XPath, provide '-' names as well
55
   (:export "after"
56
            "before"
57
            "PeriodOverlaps"
58
            "period-overlaps"
59
            "starts"
60
            "during"
61
            "finishes"
62
            "PeriodContains"
63
            "period-contains"
64
            "meets"
65
            "isMetBy"
66
            "is-met-by"
67
            "equalsPeriod"
68
            "equals-period"
69
            "overRight"
70
            "over-right"
71
            "overLeft"
72
            "over-left"
73
            "nequalsPeriod"
74
            "nequals-period"
75
            "meetsBefore"
76
            "meets-before"
77
            "meetsAfter"
78
            "meets-after"
79
            "period"
80
            "period_intersect"
81
            "period_start"
82
            "period_end"
83
            "period_preceeding"
84
            "period-succeeding"))
85
 
86
 (add-iri-package "http://strdf.di.uoa.gr/ontology#")
87
 
88
 (defpackage :strdf
89
   (:documentation "The strabon definition home package")
90
   (:use ))
91
 
92
 
93
 ;;;
94
 
95
 (defmacro |time|:|intervalAfter|  (i1 i2)
96
  "returns true if i1 happens after i2."
97
   `(strdf::after ,i1 ,i2))
98
 (defmacro |strdf|:|after| (i1 i2)
99
  "returns true if i1 happens after i2."
100
   `(strdf::after ,i1 ,i2))
101
 
102
 (defun strdf::after (i1 i2)
103
   "returns true if i1 happens after i2."
104
   (declare (type spocq:interval i1 i2))
105
   (spocq.e:>= (spocq:interval-start i1) (spocq:interval-end i2)))
106
 
107
 
108
 (defmacro |strdf|:|before| (i1 i2)
109
   "returns true if i1 happens before i2."
110
   `(strdf::after ,i1 ,i2))
111
 
112
 (defun strdf::before (i1 i2)
113
   "returns true if i1 happens before i2."
114
   (declare (type spocq:interval i1 i2))
115
   (spocq.e:<= (spocq:interval-end i1) (spocq:interval-start i2)))
116
 
117
 (defmethod spocq.e:< ((i1 spocq:interval) (i2 spocq:interval))
118
   (strdf::before i1 i2))
119
 
120
 
121
 (defmacro |strdf|:|PeriodOverlaps| (i1 i2)
122
   `(strdf::period-overlaps ,i1 ,i2))
123
 
124
 (defmacro |strdf|:|period-overlaps| (i1 i2)
125
   `(strdf::period-overlaps ,i1 ,i2))
126
 
127
 (defgeneric strdf::period-overlaps (i1 i2)
128
   (:documentation "returns true if i1 overlaps with period i2.")
129
   (:method ((i1 spocq:interval) (i2 spocq:interval))
130
     (or (strdf::period-overlaps (spocq:interval-start i1) i2)
131
         (strdf::period-overlaps (spocq:interval-start i2) i1)))
132
   (:method ((l1 spocq::temporal-location) (l2 spocq:interval))
133
     (let ((test-location (spocq:temporal-timeline-location l1)))
134
       (and (>= test-location (spocq:temporal-timeline-location (spocq::interval-start l2)))
135
            (< test-location (spocq:temporal-timeline-location (spocq::interval-end l2))))))
136
   (:method ((l2 spocq:interval) (l1 spocq::temporal-location))
137
     (let ((test-location (spocq:temporal-timeline-location l1)))
138
       (and (>= test-location (spocq:temporal-timeline-location (spocq::interval-start l2)))
139
            (< test-location (spocq:temporal-timeline-location (spocq::interval-end l2)))))))
140
 
141
 (defgeneric strdf::starts (i1 i2)
142
   (:documentation "returns true if i1 starts at the same time as period i2.")
143
   (:method ((i1 spocq:interval) (i2 spocq:interval))))
144
 
145
 (defgeneric strdf::during (i1 i2)
146
   (:documentation "returns true if i1 is contained by with period i2.")
147
   (:method ((i1 spocq:interval) (i2 spocq:interval))))
148
 
149
 (defgeneric strdf::finishes (i1 i2)
150
   (:documentation "returns true if i1 finishes at the same time as period i2.")
151
   (:method ((i1 spocq:interval) (i2 spocq:interval))))
152
 
153
 
154
 (defmacro |strdf|:|PeriodContains| (i1 i2)
155
   `(strdf::period-contains ,i1 ,i2))
156
 
157
 (defgeneric strdf::period-contains (interval instant)
158
   (:documentation "returns true if period interval contains instant instant.")
159
   (:method ((i1 spocq:interval) (i2 spocq:interval))
160
     )
161
   (:method ((i1 spocq:date-time-interval) (location spocq:date-time))
162
     )
163
 
164
   (:method ((i1 spocq:time-interval) (location spocq:time))
165
     )
166
 
167
   (:method ((i1 spocq:date-interval) (location spocq:date))
168
     ))
169
 
170
 (defgeneric strdf::meets (i1 i2)
171
   (:documentation "returns true if i1 meets period i2.")
172
   (:method ((i1 spocq:interval) (i2 spocq:interval))))
173
 
174
 (defgeneric strdf::is-met-by (i1 i2)
175
   (:documentation "returns true if i2 meets period i1.")
176
   (:method ((i1 spocq:interval) (i2 spocq:interval))))
177
 
178
 (defgeneric strdf::equals-period (interval1 interval2)
179
   (:documentation "returns true if i1 is cotemporal with period i2.")
180
 
181
   (:method ((i1 spocq:interval) (i2 spocq:interval))
182
     (and (spocq.e:= (spocq::interval-start i1) (spocq::interval-start i2))
183
          (spocq.e:= (spocq::interval-end i1) (spocq::interval-end i2)))))
184
 
185
 (defmethod spocq.e:= ((i1 spocq:interval) (i2 spocq:interval))
186
   (strdf::equals-period i1 i2))
187
 
188
 (defmethod spocq.e:<= ((i1 spocq:interval) (i2 spocq:interval))
189
   (or (strdf::before i1 i2)
190
       (strdf::equals-period i1 i2)))
191
 
192
 
193
 (defun strdf::overright (interval1 interval2)
194
   "returns true if all values of i1 are greater than or equal to the start of  period i2."
195
   (spocq.e:>= (spocq:interval-start interval1) (spocq:interval-start interval2)))
196
 
197
 (defun strdf::overleft (interval1 interval2)
198
   "returns true if all values of i1 are greater than or equal to the end of  period i2."
199
   (spocq.e:>= (spocq:interval-start interval1) (spocq:interval-end interval2)))
200
 
201
 (defun strdf::nequals-period (interval1 interval2)
202
   "returns true if i1 is not contemporal with period i2."
203
   (not (strdf::equals-period interval1 interval2)))
204
 
205
 (defun strdf::meets-before (interval1 interval2)
206
   "returns true if i1 meets period i2 and i1  started before i2."
207
   (and (spocq.e:< (spocq:interval-start interval1) (spocq:interval-start interval2))
208
        (spocq.e:>= (spocq:interval-end interval1) (spocq:interval-start interval2))
209
        (spocq.e:<= (spocq:interval-end interval1) (spocq:interval-end interval2))))
210
 
211
 (defun strdf::meets-after (interval1 interval2)
212
   "returns true if i1 meets period i2 and i1  started after i2."
213
   (and (spocq.e:> (spocq:interval-start interval1) (spocq:interval-start interval2))
214
        (spocq.e:>= (spocq:interval-end interval1) (spocq:interval-start interval2))
215
        (spocq.e:<= (spocq:interval-end interval1) (spocq:interval-end interval2))))
216
 
217
 
218
 
219
 (defun strdf::period-intersect (interval1 interval2)
220
   "This function returns the temporal intersection of period p1 with period p2.
221
    A literal of strdf:period or xsd:dateTime will be returned."
222
   (declare (ignore interval1 interval2))
223
   )
224
 
225
 (defun strdf::minus (interval1 interval2)
226
   "This function returns the temporal intersection of period p1 with period p2.
227
    A literal of strdf:period or xsd:dateTime will be returned."
228
   (declare (ignore interval1 interval2)))
229
 
230
 (defun strdf::period-preceeding (interval1 interval2)
231
   "This function returns the part of period p1 that preceeds period p2."
232
   (declare (ignore interval1 interval2)))
233
 
234
 (defun strdf::period_succeeding (interval1 interval2)
235
   "This function returns the part of period p1 that succeeds period p2."
236
   (declare (ignore interval1 interval2)))
237
 
238
 (defun strdf::period (location1 location2)
239
   "This function constructs a period starting from instant i1 and ending to instant i2."
240
   (declare (ignore location1 location2)))
241
 
242
 (defun strdf::period-start (interval)
243
   "This function returns the starting point of period p."
244
   (declare (ignore interval)))
245
 
246
 (defun strdf::period-end (interval)
247
   "This function returns the ending point of period p."
248
   (declare (ignore interval)))