@@ -166,7 +166,7 @@ test_pairs = [
166
166
const ϵ = 1e-10
167
167
# Compare clipping results from GeometryOps and LibGEOS
168
168
function compare_GO_LG_clipping (GO_f, LG_f, p1, p2)
169
- GO_result_list = GO_f (p1, p2; target = GI . PolygonTrait ())
169
+
170
170
LG_result_geom = LG_f (p1, p2)
171
171
if LG_result_geom isa LG. GeometryCollection
172
172
poly_list = LG. Polygon[]
@@ -175,38 +175,43 @@ function compare_GO_LG_clipping(GO_f, LG_f, p1, p2)
175
175
end
176
176
LG_result_geom = LG. MultiPolygon (poly_list)
177
177
end
178
- # Check if nothing is returned
179
- if isempty (GO_result_list) && (LG. isEmpty (LG_result_geom) || LG. area (LG_result_geom) == 0 )
180
- return true
181
- end
182
- # Check for unnecessary points
183
- if sum (GI. npoint, GO_result_list; init = 0.0 ) > GI. npoint (LG_result_geom)
184
- return false
185
- end
186
- # Make sure last point is repeated
187
- for poly in GO_result_list
188
- for ring in GI. getring (poly)
189
- GI. getpoint (ring, 1 ) != GI. getpoint (ring, GI. npoint (ring)) && return false
178
+
179
+ for _accelerator in (GO. AutoAccelerator (), GO. NestedLoop (), GO. SingleSTRtree (), GO. SingleNaturalTree (), #= GO.DoubleNaturalTree(), =# #= GO.ThinnedDoubleNaturalTree(), =# #= GO.DoubleSTRtree()=# )
180
+ @testset let accelerator = _accelerator # this is a ContextTestSet that is otherwise invisible but adds context to the testset
181
+ GO_result_list = GO_f (GO. FosterHormannClipping (accelerator), p1, p2; target = GI. PolygonTrait ())
182
+ # Check if nothing is returned
183
+ if isempty (GO_result_list) && (LG. isEmpty (LG_result_geom) || LG. area (LG_result_geom) == 0 )
184
+ @test true
185
+ continue
186
+ end
187
+ # Check for unnecessary points
188
+ @test ! (sum (GI. npoint, GO_result_list; init = 0.0 ) > GI. npoint (LG_result_geom))
189
+ # Make sure last point is repeated
190
+ for poly in GO_result_list
191
+ for ring in GI. getring (poly)
192
+ @test ! (GI. getpoint (ring, 1 ) != GI. getpoint (ring, GI. npoint (ring)))
193
+ end
190
194
end
191
- end
192
195
193
- # Check if polygons cover the same area
194
- local GO_result_geom
195
- if length (GO_result_list) == 1
196
- GO_result_geom = GO_result_list[1 ]
197
- else
198
- GO_result_geom = GI. MultiPolygon (GO_result_list)
199
- end
200
- diff_1_area = LG. area (LG. difference (GO_result_geom, LG_result_geom))
201
- diff_2_area = LG. area (LG. difference (LG_result_geom, GO_result_geom))
202
- return diff_1_area ≤ ϵ && diff_2_area ≤ ϵ
196
+ # Check if polygons cover the same area
197
+ local GO_result_geom
198
+ if length (GO_result_list) == 1
199
+ GO_result_geom = GO_result_list[1 ]
200
+ else
201
+ GO_result_geom = GI. MultiPolygon (GO_result_list)
202
+ end
203
+ diff_1_area = LG. area (LG. difference (GO_result_geom, LG_result_geom))
204
+ diff_2_area = LG. area (LG. difference (LG_result_geom, GO_result_geom))
205
+ @test diff_1_area ≤ ϵ && diff_2_area ≤ ϵ
206
+ end # testset
207
+ end # loop
203
208
end
204
209
205
210
# Test clipping functions and print error message if tests fail
206
211
function test_clipping (GO_f, LG_f, f_name)
207
212
for (p1, p2, sg1, sg2, sdesc) in test_pairs
208
213
@testset_implementations " $sg1 $f_name $sg2 - $sdesc " begin
209
- @test compare_GO_LG_clipping (GO_f, LG_f, $ p1, $ p2)
214
+ compare_GO_LG_clipping (GO_f, LG_f, $ p1, $ p2) # this executes tests internally
210
215
end
211
216
end
212
217
return
0 commit comments