Coverage report: /development/source/library/org/datagraph/spocq-shard/src/algebra/operators/strbon-allen.lisp
| Kind | Covered | All | % |
| expression | 0 | 122 | 0.0 |
| branch | 0 | 12 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
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
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.
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.
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
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#> ")
49
(defpackage "http://strdf.di.uoa.gr/ontology#"
50
;; http://www.strabon.di.uoa.gr/download.html
53
(:documentation "The strabon interface package")
54
;; consistent with XPath, provide '-' names as well
86
(add-iri-package "http://strdf.di.uoa.gr/ontology#")
89
(:documentation "The strabon definition home package")
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))
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)))
108
(defmacro |strdf|:|before| (i1 i2)
109
"returns true if i1 happens before i2."
110
`(strdf::after ,i1 ,i2))
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)))
117
(defmethod spocq.e:< ((i1 spocq:interval) (i2 spocq:interval))
118
(strdf::before i1 i2))
121
(defmacro |strdf|:|PeriodOverlaps| (i1 i2)
122
`(strdf::period-overlaps ,i1 ,i2))
124
(defmacro |strdf|:|period-overlaps| (i1 i2)
125
`(strdf::period-overlaps ,i1 ,i2))
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)))))))
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))))
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))))
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))))
154
(defmacro |strdf|:|PeriodContains| (i1 i2)
155
`(strdf::period-contains ,i1 ,i2))
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))
161
(:method ((i1 spocq:date-time-interval) (location spocq:date-time))
164
(:method ((i1 spocq:time-interval) (location spocq:time))
167
(:method ((i1 spocq:date-interval) (location spocq:date))
170
(defgeneric strdf::meets (i1 i2)
171
(:documentation "returns true if i1 meets period i2.")
172
(:method ((i1 spocq:interval) (i2 spocq:interval))))
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))))
178
(defgeneric strdf::equals-period (interval1 interval2)
179
(:documentation "returns true if i1 is cotemporal with period i2.")
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)))))
185
(defmethod spocq.e:= ((i1 spocq:interval) (i2 spocq:interval))
186
(strdf::equals-period i1 i2))
188
(defmethod spocq.e:<= ((i1 spocq:interval) (i2 spocq:interval))
189
(or (strdf::before i1 i2)
190
(strdf::equals-period i1 i2)))
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)))
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)))
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)))
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))))
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))))
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))
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)))
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)))
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)))
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)))
242
(defun strdf::period-start (interval)
243
"This function returns the starting point of period p."
244
(declare (ignore interval)))
246
(defun strdf::period-end (interval)
247
"This function returns the ending point of period p."
248
(declare (ignore interval)))