rust-postgis
An extension to rust-postgres, adds support for PostGIS.
- PostGIS type helper
- GCJ02 support (used offically in Mainland China)
- Tiny WKB (TWKB) support
Usage
use ;
use ewkb;
use LineString;
Handling NULL values:
let route = row.;
match route.unwrap
Writing other geometry types into PostGIS
rust-postgis supports writing geometry types into PostGIS which implement the following traits:
Point
,LineString
, ...AsEwkbPoint
,AsEwkbLineString
, ...
See the TWKB implementation as an example.
An example for reading a TWKB geometry and writing it back as EWKB:
use twkb;
use LineString;
for row in &conn.query.unwrap
Unit tests
Unit tests which need a PostgreSQL connection are ignored by default.
To run the database tests, declare the connection in an environment variable DBCONN
. Example:
export DBCONN=postgresql://user@localhost/testdb
Run the tests with
cargo test -- --ignored