https://github.com/amandasaurus/rust-wkb
Read & Write Well Known Binary in Rust
https://github.com/amandasaurus/rust-wkb
Last synced: 3 months ago
JSON representation
Read & Write Well Known Binary in Rust
- Host: GitHub
- URL: https://github.com/amandasaurus/rust-wkb
- Owner: amandasaurus
- License: agpl-3.0
- Created: 2017-08-04T18:22:09.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2022-08-01T17:15:27.000Z (almost 3 years ago)
- Last Synced: 2025-03-23T02:34:14.853Z (3 months ago)
- Language: Rust
- Homepage:
- Size: 41 KB
- Stars: 7
- Watchers: 1
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.adoc
Awesome Lists containing this project
README
# `rust-wkb`
This crate provides functions to convert `rust-geo` geometry types to and from [Well Known Binary](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry#Well-known_binary) format, i.e. [ISO 19125](https://www.iso.org/standard/40114.html)
## Examples
```rust
use geo_types::*;
use wkb::*;let p: Geometry = Geometry::Point(Point::new(2., 4.));
let res = geom_to_wkb(&p);
assert_eq!(res, vec![1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 16, 64]);
```You can also 'read' a Geometry from a `std::io::Read`:
```rust
use geo_types::*;
use wkb::*;let bytes: Vec = vec![1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 16, 64];
let p: Geometry = wkb_to_geom(&mut bytes.as_slice()).unwrap();
assert_eq!(p, Geometry::Point(Point::new(2., 4.)));
```Adding proper `*Ext` traits is planned.