Crate postgis[−][src]
Expand description
An extension to rust-postgres, adds support for PostGIS.
- PostGIS type helper
- GCJ02 support (used offically in Mainland China)
- Tiny WKB (TWKB) support
use postgres::{Client, NoTls};
use postgis::{ewkb, LineString};
fn main() {
let mut client = Client::connect("host=localhost user=postgres", NoTls).unwrap();
for row in &client.query("SELECT * FROM busline", &[]).unwrap() {
let route: ewkb::LineString = row.get("route");
let last_stop = route.points().last().unwrap();
let _ = client.execute("INSERT INTO stops (stop) VALUES ($1)", &[&last_stop]);
}
}
Handling NULL values:
let route = row.try_get::<_, Option<ewkb::LineString>>("route");
match route {
Ok(Some(geom)) => { println!("{:?}", geom) }
Ok(None) => { /* Handle NULL value */ }
Err(err) => { println!("Error: {}", err) }
}
Modules
Read and write geometries in OGC WKB format.
Conversion between GCJ-02 and WGS-84 coordinates.
Read geometries in Tiny WKB format.