@@ -431,21 +431,48 @@ end
431431 # GEOSNearestPointsTest
432432 geom1_ = LibGEOS. readgeom (" POLYGON EMPTY" )
433433 geom2_ = LibGEOS. readgeom (" POLYGON EMPTY" )
434+ prepGeom1_ = LibGEOS. prepareGeom (geom1_)
434435 @test LibGEOS. nearestPoints (geom1_, geom2_) == Point[]
436+ @test LibGEOS. nearestPoints (prepGeom1_, geom2_) == Point[]
435437 LibGEOS. destroyGeom (geom1_)
436438 LibGEOS. destroyGeom (geom2_)
439+ LibGEOS. destroyPreparedGeom (prepGeom1_)
437440
438- geom1_ = LibGEOS. readgeom (" POLYGON((1 1,1 5,5 5,5 1,1 1))" )
439- geom2_ = LibGEOS. readgeom (" POLYGON((8 8, 9 9, 9 10, 8 8))" )
440- coords_ = LibGEOS. nearestPoints (geom1_, geom2_)
441- @test coords_ isa Vector{Point}
442- @test length (coords_) == 2
443- @test GeoInterface. coordinates (coords_[1 ]) ≈ [5.0 , 5.0 ] atol = 1e-5
444- @test GeoInterface. coordinates (coords_[2 ]) ≈ [8.0 , 8.0 ] atol = 1e-5
445- LibGEOS. destroyGeom (geom1_)
446- LibGEOS. destroyGeom (geom2_)
447- LibGEOS. destroyGeom (coords_[1 ])
448- LibGEOS. destroyGeom (coords_[2 ])
441+ for (wkt1_, wkt2_, wkt3_, wkt4_) in [
442+ [" POLYGON((1 1,1 5,5 5,5 1,1 1))" , " POLYGON((8 8, 9 9, 9 10, 8 8))" , " POINT(5 5)" , " POINT(8 8)" ],
443+ [" POLYGON((1 1,1 5,5 5,5 1,1 1))" , " POINT(2 2)" , " POINT(2 2)" , " POINT(2 2)" ],
444+ [" LINESTRING(1 5,5 5,5 1,1 1)" , " POINT(2 2)" , " POINT(2 1)" , " POINT(2 2)" ],
445+ [" LINESTRING(0 0,10 10)" , " LINESTRING(0 10,10 0)" , " POINT(5 5)" , " POINT(5 5)" ],
446+ [" POLYGON((0 0,10 0,10 10,0 10,0 0))" , " LINESTRING(8 5,12 5)" , " POINT(8 5)" , " POINT(8 5)" ]
447+ ]
448+ geom1_ = LibGEOS. readgeom (wkt1_)
449+ geom2_ = LibGEOS. readgeom (wkt2_)
450+ geom3_ = LibGEOS. readgeom (wkt3_)
451+ geom4_ = LibGEOS. readgeom (wkt4_)
452+ prepGeom1_ = LibGEOS. prepareGeom (geom1_)
453+
454+ coords_ = LibGEOS. nearestPoints (geom1_, geom2_)
455+ @test coords_ isa Vector{Point}
456+ @test length (coords_) == 2
457+ @test LibGEOS. equals (coords_[1 ], geom3_)
458+ @test LibGEOS. equals (coords_[2 ], geom4_)
459+
460+ prepCoords_ = LibGEOS. nearestPoints (prepGeom1_, geom2_)
461+ @test prepCoords_ isa Vector{Point}
462+ @test length (prepCoords_) == 2
463+ @test LibGEOS. equals (prepCoords_[1 ], geom3_)
464+ @test LibGEOS. equals (prepCoords_[2 ], geom4_)
465+
466+ LibGEOS. destroyGeom (geom1_)
467+ LibGEOS. destroyGeom (geom2_)
468+ LibGEOS. destroyGeom (geom3_)
469+ LibGEOS. destroyGeom (geom4_)
470+ LibGEOS. destroyGeom (coords_[1 ])
471+ LibGEOS. destroyGeom (coords_[2 ])
472+ LibGEOS. destroyGeom (prepCoords_[1 ])
473+ LibGEOS. destroyGeom (prepCoords_[2 ])
474+ LibGEOS. destroyPreparedGeom (prepGeom1_)
475+ end
449476
450477 # GEOSNodeTest
451478 geom1_ = LibGEOS. readgeom (" LINESTRING(0 0, 10 10, 10 0, 0 10)" )
0 commit comments