summaryrefslogtreecommitdiff
path: root/ext/librethinkdbxx/test/upstream/geo/intersection_inclusion.yaml
blob: 18a643a0350569170ff62b791f634115927dfac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
desc: Test intersects and includes semantics
tests:
  # Intersects
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.point(1.5,1.5))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.point(2.5,2.5))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.point(1.5,1.5))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.point(1.05,1.05))
    ot: true
  # Our current semantics: we define polygons as closed, so points that are exactly *on* the outline of a polygon do intersect
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.point(2,2))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.point(2,1.5))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.line([1.5,1.5], [2,2]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.line([1.5,1.5], [2,1.5]))
    ot: true
  # (...with holes in the polygon being closed with respect to the polygon, i.e. the set cut out is open)
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.point(1.1,1.1))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.point(1.5,1.1))
    ot: true
  # ... lines are interpreted as closed sets as well, so even if they meet only at their end points, we consider them as intersecting.
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.line([2,2], [3,3]))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.line([2,1.5], [3,3]))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.line([1.5,1.5], [3,3]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.polygon([1.2,1.2], [1.8,1.2], [1.8,1.8], [1.2,1.8]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.polygon([1.5,1.5], [2.5,1.5], [2.5,2.5], [1.5,2.5]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.polygon([1.2,1.2], [1.8,1.2], [1.8,1.8], [1.2,1.8]))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9]))
    ot: false
  # Polygons behave like lines in that respect
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.polygon([2,1.1], [3,1.1], [3,1.9], [2,1.9]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.polygon([2,2], [3,2], [3,3], [2,3]))
    ot: false
  - cd: r.point(1,1).intersects(r.point(1.5,1.5))
    ot: false
  - cd: r.point(1,1).intersects(r.point(1,1))
    ot: true
  - cd: r.line([1,1], [2,1]).intersects(r.point(1,1))
    ot: true
  # This one currently fails due to numeric precision problems.
  #- cd: r.line([1,0], [2,0]).intersects(r.point(1.5,0))
  #  ot: true
  - cd: r.line([1,1], [1,2]).intersects(r.point(1,1.8))
    ot: true
  - cd: r.line([1,0], [2,0]).intersects(r.point(1.8,0))
    ot: true
  - cd: r.line([1,1], [2,1]).intersects(r.point(1.5,1.5))
    ot: false
  - cd: r.line([1,1], [2,1]).intersects(r.line([2,1], [3,1]))
    ot: true
  # intersects on an array/stream
  - cd: r.expr([r.point(1, 0), r.point(3,0), r.point(2, 0)]).intersects(r.line([0,0], [2, 0])).count()
    ot: 2
  
  # Includes
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.point(1.5,1.5))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.point(2.5,2.5))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.point(1.5,1.5))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.point(1.05,1.05))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.point(2,2))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.point(2,1.5))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([1.5,1.5], [2,2]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([1.5,1.5], [2,1.5]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.point(1.1,1.1))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.point(1.5,1.1))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([2,2], [3,3]))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([2,1.5], [2,2]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([2,1], [2,2]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([1.5,1.5], [3,3]))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([1,1], [2,1], [2,2], [1,2]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([1.2,1.2], [1.8,1.2], [1.8,1.8], [1.2,1.8]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([1.5,1.5], [2,1.5], [2,2], [1.5,2]))
    ot: true
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([1.5,1.5], [2.5,1.5], [2.5,2.5], [1.5,2.5]))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.polygon([1.2,1.2], [1.8,1.2], [1.8,1.8], [1.2,1.8]))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.polygon([1.1,1.1], [2,1.1], [2,2], [1.1,2]))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([2,1.1], [3,1.1], [3,1.9], [2,1.9]))
    ot: false
  - cd: r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([2,2], [3,2], [3,3], [2,3]))
    ot: false
  # includes on an array/stream
  - cd: r.expr([r.polygon([0,0], [1,1], [1,0]), r.polygon([0,1], [1,2], [1,1])]).includes(r.point(0,0)).count()
    ot: 1
  # Wrong geometry type arguments (the first one must be a polygon)
  - cd: r.point(0,0).includes(r.point(0,0))
    ot: err('ReqlQueryLogicError', 'Expected geometry of type `Polygon` but found `Point`.')
  - cd: r.line([0,0], [0,1]).includes(r.point(0,0))
    ot: err('ReqlQueryLogicError', 'Expected geometry of type `Polygon` but found `LineString`.')