Skip to content

Commit

Permalink
Add test from PostGIS SnapToGrid issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Sep 12, 2023
1 parent 135e676 commit 73be95d
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions tests/unit/capi/GEOSGeom_setPrecisionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,23 @@ void object::test<12>()
ensure_equals(GEOSGeom_getCoordinateDimension(geom2_), 2);
}

//-- test that a large gridsize works
template<>
template<>
void object::test<13>()
{
geom1_ = fromWKT("LINESTRING (657035.913 6475590.114,657075.57 6475500)");
geom2_ = GEOSGeom_setPrecision(geom1_, 100, 0);
//std::cout << toWKT(geom2_) << std::endl;
ensure_geometry_equals(geom2_,
"LINESTRING (657000 6475600, 657100 6475500)");
}

// Test more exact rounding for integral scale factors
// see https://trac.osgeo.org/postgis/ticket/5520
template<>
template<>
void object::test<13>()
void object::test<14>()
{
geom1_ = fromWKT("LINESTRING (657035.913 6475590.114,657075.57 6475500)");
geom2_ = GEOSGeom_setPrecision(geom1_, .001, 0);
Expand All @@ -214,17 +226,19 @@ void object::test<13>()
"LINESTRING (657035.913 6475590.114, 657075.57 6475500)");
}

//-- test that a large gridsize works
// see https://trac.osgeo.org/postgis/ticket/5425
template<>
template<>
void object::test<14>()
void object::test<15>()
{
geom1_ = fromWKT("LINESTRING (657035.913 6475590.114,657075.57 6475500)");
geom2_ = GEOSGeom_setPrecision(geom1_, 100, 0);
geom1_ = fromWKT("LINESTRING(674169.89 198051.38,674197.7 198065.55,674200.36 198052.38)");
geom2_ = GEOSGeom_setPrecision(geom1_, .001, 0);
//std::cout << toWKT(geom2_) << std::endl;
ensure_geometry_equals(geom2_,
"LINESTRING (657000 6475600, 657100 6475500)");
"LINESTRING (674169.89 198051.38, 674197.7 198065.55, 674200.36 198052.38)");
}



} // namespace tut

0 comments on commit 73be95d

Please sign in to comment.