Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ A utility library for converting decimal [WGS84](http://spatialreference.org/ref
Conversion is handled by a [Rust binary](https://github.com/urschrei/rust_bng) using FFI, and is quite fast. Some benchmarks can be found [here](https://github.com/urschrei/lonlat_bng#benchmark).

# Installation
- `pip install convertbng`
- `uv add convertbng`
- `pip install convertbng`

## Installing for local development
1. Ensure you have a copy of `liblonlat_bng` and `header.h` from https://github.com/urschrei/lonlat_bng/releases, and it's in the `src/convertbng` subdir
Expand Down Expand Up @@ -65,6 +65,17 @@ lats_np = np.array(lats)
res_list_np = convert_bng(lons_np, lats_np)
```

# Accuracy
The [Rust library](https://github.com/urschrei/lonlat_bng) produces the following results when round-tripping the 40 OSTN15 test points (only differences are shown)

| Test Point | Input OSGB36 E (m) | Input OSGB36 N (m) | Lon diff (°) | Lat diff (°) | E diff (m) | N diff (m) |
|:-----------|-------------------:|-------------------:|-------------:|-------------:|-----------:|-----------:|
| TP27 | 319188.434 | 670947.534 | — | — | — | +0.001 |
| TP31 | 9587.909 | 899448.996 | +6×10⁻⁸ | -3×10⁻⁸ | +0.003 | -0.004 |
| TP32 | 71713.132 | 938516.404 | +2×10⁻⁸ | -1×10⁻⁸ | +0.001 | -0.002 |
| TP37 | 180862.461 | 1029604.114 | — | — | — | -0.001 |
| TP38 | 421300.525 | 1072147.239 | — | — | — | -0.001 |

# Cython Module
If you're comfortable with restricting yourself to `NumPy f64` arrays, you may use the Cython functions instead. These are identical to those listed below, but performance on large datasets is better. They are selected by changing the import statement
`from convertbng.util import` to
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "convertbng"
version = "0.7.9"
version = "0.7.10"
description = "Fast lon, lat to and from ETRS89 and BNG (OSGB36) using the OS OSTN15 transform via Rust FFI"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
10 changes: 5 additions & 5 deletions tests/test_convertbng.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def test_non_convergence(self):
[408884, 333642],
]
expected = [
[-1.92485417, 53.26107641],
[-1.6233221, 52.06744836],
[-1.86937174, 52.90016459],
[-1.92485417, 53.26107642],
[-1.62332209, 52.06744836],
[-1.86937175, 52.9001646],
]
for i, j in zip(extremes, expected):
exp = ([j[0]], [j[1]])
Expand All @@ -91,7 +91,7 @@ def test_non_convergence(self):

def testConvertBNG(self):
"""Test multithreaded BNG --> lon, lat function"""
expected = ([-0.32822654, -2.01831267], [51.44533145, 54.58910534])
expected = ([-0.32822654, -2.01831268], [51.44533144, 54.58910534])
result = convert_lonlat([516276, 398915], [173141, 521545])
self.assertEqual(expected, result)

Expand Down Expand Up @@ -231,7 +231,7 @@ def test_etrs89_to_osgb36(self):

def test_osgb36_to_etrs89(self):
"""Tests OSGB36 --> ETRS89 Eastings, Northings conversion"""
expected = ([651307.003], [313255.686])
expected = ([651307.0032098937], [313255.68598407705])
result = convert_osgb36_to_etrs89(651409.804, 313177.45)
self.assertEqual(expected, result)

Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading