Skip to content

Commit

Permalink
21 operators add unitconvert (#22)
Browse files Browse the repository at this point in the history
* add unit convert operator

* units and things

* testing helpers

* add angular units and format to table like

* tests and move common steps to constructor

* tidy ups

* update readme

* bump version and changelog update
  • Loading branch information
Rennzie authored Oct 5, 2023
1 parent a056da0 commit 18dddbc
Show file tree
Hide file tree
Showing 8 changed files with 431 additions and 5 deletions.
16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security - in case of vulnerabilities.
-->

## [0.2.0] - 2021-10-21
## [0.3.0] - 2023-10-05

### Added

- `unitconvert` operator [#21](https://github.com/Rennzie/geodesy-wasm/issues/21)

### Fixed

- The dates in this change log. Blindly following Github Copilot is a mistake

## [0.2.0] - 2023-09-23

- Move test.js to examples folder [#18](https://github.com/Rennzie/geodesy-wasm/issues/18)
- Added 00-basic examples
Expand All @@ -23,14 +33,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added performance benchmarks vs proj4.js [#11](https://github.com/Rennzie/geodesy-wasm/issues/11)
- Improved performance to JS Wrapper code

## [0.2.0-beta2] - 2021-10-20
## [0.2.0-beta2] - 2021-09-23

### Added

- ESM Build [#16](https://github.com/Rennzie/geodesy-wasm/issues/16)
- Example usage in ObservableHQ

## [0.2.0-beta1] - 2021-10-20
## [0.2.0-beta1] - 2021-09-23

### Added

Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "geodesy-wasm"
version = "0.2.0"
version = "0.3.0"
keywords = ["geospatial", "geodesy", "cartography", "geography"]
categories = ["science"]
authors = ["Sean Rennie <[email protected]>"]
Expand Down Expand Up @@ -33,6 +33,7 @@ js-sys = "0.3.64"
thiserror = "1.0.44"
console_log = { version = "1.0.0", features = ["color"], optional = true }
log = "0.4.19"
float_eq = "1.0.1"

[dev-dependencies]
wasm-bindgen-test = "0.3.37"
Expand Down
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ _Note: Please see the [warnings](https://github.com/busstoptaktik/geodesy?tab=re
1. Being added in the geodesy crate [here](https://github.com/busstoptaktik/geodesy/pull/60) but is already being used in geodesy-wasm in place of gravsoft grid support.
5. [x] Usage guide and examples
6. [ ] Documentation
7. [ ] Publish v1.0.0
7. [ ] Add operators for better parity with PROJ
1. [x] unitconvert
2. [ ] hgridshift
3. [ ] longlat?
4. [ ] axisswap?

Contributions very much welcome!

Expand Down Expand Up @@ -54,6 +58,26 @@ ts-node examples/js/00-basic.ts

See [this notebook](https://observablehq.com/d/3ff9d9b8f0b5168a) for an example of using Geodesy-Wasm in ObservableHQ.

## 📚 Documentation

### Operators

Geodesy wasm provides some limited operators that are not on the Rust Geodesy road map. Mostly this will be to get closer to PROJ. The operators are:

#### unitconvert

Used for converting horizontal and vertical units. Note, time units are not supported. See units.rs for a list of supported units.

```js
import {Geodesy} from 'geodesy-wasm';
let ctx = new Geodesy('unitconvert xy_in=deg xy_out=rad');
let result = ctx.forward([[1, 2]]);
console.log(result); // [0.017453292519943295, 0.03490658503988659]

let reverse = ctx.reverse(result);
console.log(reverse); // [1, 2]
```

## Development

For convenience all scripts can be run with `bun <script>`. Make sure all the javascript related dependencies are installed with `bun install`. Rust dependencies are managed by [cargo](https://doc.rust-lang.org/cargo/) and don't require and explicit install step.
Expand Down
1 change: 1 addition & 0 deletions src/geodesy/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod context;
mod coordinate;
mod grid;
mod operators;
mod wasmcontext;
9 changes: 9 additions & 0 deletions src/geodesy/operators/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use geodesy_rs::authoring::*;

mod unitconvert;
pub mod units;

#[rustfmt::skip]
pub const ACCESSORY_OPERATORS: [(&str, OpConstructor); 1] = [
("unitconvert", OpConstructor(unitconvert::new))
];
Loading

0 comments on commit 18dddbc

Please sign in to comment.