1818)
1919
2020
21+ def _round8 (result ):
22+ """Round a (eastings/lons, northings/lats) FFI result to 8 decimal places.
23+
24+ The Rust library returns longitude/latitude at full f64 precision. The
25+ published reference values are meaningful to ~8 d.p. (sub-millimetre), and
26+ trig-derived coordinates are not bit-stable across the platforms convertbng
27+ ships wheels for, so lon/lat results are compared at 8 d.p.
28+ """
29+ return ([round (v , 8 ) for v in result [0 ]], [round (v , 8 ) for v in result [1 ]])
30+
31+
2132class ConvertbngTests (unittest .TestCase ):
2233 """Tests for convert_bng"""
2334
@@ -85,13 +96,13 @@ def test_non_convergence(self):
8596 for i , j in zip (extremes , expected ):
8697 exp = ([j [0 ]], [j [1 ]])
8798 converted = convert_lonlat ([i [0 ]], [i [1 ]])
88- self .assertEqual (exp , converted )
99+ self .assertEqual (exp , _round8 ( converted ) )
89100
90101 def testConvertBNG (self ):
91102 """Test multithreaded BNG --> lon, lat function"""
92103 expected = ([- 0.32822654 , - 2.01831268 ], [51.44533144 , 54.58910534 ])
93104 result = convert_lonlat ([516276 , 398915 ], [173141 , 521545 ])
94- self .assertEqual (expected , result )
105+ self .assertEqual (expected , _round8 ( result ) )
95106
96107 def testConvertLonLatSingle (self ):
97108 """Test lon, lat --> BNG conversion of single values"""
@@ -107,7 +118,7 @@ def testConvertTuple(self):
107118
108119 def testConvertString (self ):
109120 """Test that an error is thrown for incorrect types"""
110- with self .assertRaises (ArgumentError ) as result :
121+ with self .assertRaises (ArgumentError ):
111122 convert_bng (["Foo" ], ["Bar" ])
112123
113124 def testConvertIterable (self ):
@@ -219,7 +230,7 @@ def test_osgb36_to_lonlat(self):
219230 # expected = [[1.716073973], [52.658007833]]
220231 expected = ([1.71607397 ], [52.65800783 ])
221232 result = convert_osgb36_to_lonlat (651409.804 , 313177.45 )
222- self .assertEqual (expected , result )
233+ self .assertEqual (expected , _round8 ( result ) )
223234
224235 def test_etrs89_to_osgb36 (self ):
225236 """Tests ETRS89 Eastings, Northings --> OSGB36 conversion"""
@@ -237,7 +248,7 @@ def test_etrs89_to_lonlat(self):
237248 """Tests ETRS89 --> Lon, Lat conversion"""
238249 expected = ([1.71607397 ], [52.65800783 ])
239250 result = convert_etrs89_to_lonlat (651307.003 , 313255.686 )
240- self .assertEqual (expected , result )
251+ self .assertEqual (expected , _round8 ( result ) )
241252
242253 def test_lonlat_to_etrs89 (self ):
243254 """Tests Lon, Lat --> ETRS89 conversion"""
@@ -247,8 +258,9 @@ def test_lonlat_to_etrs89(self):
247258
248259 def test_epsg3857_to_wgs84 (self ):
249260 """Tests EPSG3857 to WGS84 conversion"""
250- expected = ([- 5.625000000783013 ], [52.48278022732355 ])
261+ expected = ([- 5.625 ], [52.48278023 ])
251262 result = convert_epsg3857_to_wgs84 (- 626172.1357121646 , 6887893.4928337997 )
263+ self .assertEqual (expected , _round8 (result ))
252264
253265 def test_large_array (self ):
254266 """
0 commit comments