|
685 | 685 | geom_ = LibGEOS._readgeom("LINESTRING(0 0, 0 1, 1 1, 0 0)") |
686 | 686 | @test LibGEOS.isClosed(geom_) |
687 | 687 | LibGEOS.destroyGeom(geom_) |
| 688 | + |
| 689 | + # setPrecision, getPrecision |
| 690 | + # Taken from https://git.osgeo.org/gitea/geos/geos/src/branch/master/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp |
| 691 | + |
| 692 | + geom1_ = readgeom("LINESTRING(2 10, 4 30)") |
| 693 | + geom2_ = readgeom("LINESTRING(4 10, 2 30)") |
| 694 | + geom3_ = intersection(geom1_, geom2_) |
| 695 | + @test equals(geom3_, readgeom("POINT(3 20)")) |
| 696 | + |
| 697 | + g = LineString(setPrecision(geom1_, 2.0, 0)) |
| 698 | + LibGEOS.destroyGeom(geom1_) |
| 699 | + geom1_ = g |
| 700 | + g = LineString(setPrecision(geom2_, 2.0, 0)) |
| 701 | + LibGEOS.destroyGeom(geom2_) |
| 702 | + geom2_ = g |
| 703 | + geom3_ = intersection(geom1_, geom2_) |
| 704 | + @test equals(geom3_, readgeom("POINT(4 20)")) |
| 705 | + |
| 706 | + g = LineString(setPrecision(geom1_, 0.5, 0)) |
| 707 | + LibGEOS.destroyGeom(geom1_) |
| 708 | + geom1_ = g |
| 709 | + geom3_ = intersection(geom1_, geom2_) |
| 710 | + @test equals(geom3_, readgeom("POINT(3 20)")) |
| 711 | + @test getPrecision(geom1_) == 0.5 |
| 712 | + @test getPrecision(geom2_) == 2.0 |
| 713 | + |
| 714 | + geom1_ = readgeom("POLYGON((10 10,20 10,16 15,20 20, 10 20, 14 15, 10 10))") |
| 715 | + geom2_ = LibGEOS.MultiPolygon(setPrecision(geom1_, 5.0, 0)) |
| 716 | + @test equals(geom2_, readgeom( |
| 717 | + "MULTIPOLYGON (((10 10, 15 15, 20 10, 10 10)), ((15 15, 10 20, 20 20, 15 15)))")) |
| 718 | + geom3_ = LibGEOS.MultiPolygon(setPrecision(geom1_, 5.0, LibGEOS.GEOS_PREC_NO_TOPO)) |
| 719 | + @test equals(geom3_, readgeom( |
| 720 | + "POLYGON ((10 10, 20 10, 15 15, 20 20, 10 20, 15 15, 10 10))")) |
| 721 | + |
| 722 | + geom1_ = readgeom("LINESTRING(1 0, 2 0)") |
| 723 | + geom2_ = LineString(setPrecision(geom1_, 5.0, 0)) |
| 724 | + @test equals(geom2_, readgeom("LINESTRING EMPTY")) |
| 725 | + geom3_ = LineString(setPrecision(geom1_, 5.0, LibGEOS.GEOS_PREC_KEEP_COLLAPSED)) |
| 726 | + # @test equals(geom3_, readgeom("LINESTRING (0 0, 0 0)")) # false ?? |
| 727 | + @test writegeom(geom3_) == "LINESTRING (0 0, 0 0)" |
| 728 | + |
| 729 | + LibGEOS.destroyGeom(geom1_) |
| 730 | + LibGEOS.destroyGeom(geom2_) |
| 731 | + LibGEOS.destroyGeom(geom3_) |
| 732 | + LibGEOS.destroyGeom(g) |
| 733 | + |
688 | 734 | end |
0 commit comments