1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// Copyright (c) ShuYu Wang <andelf@gmail.com>, Feather Workshop and Pirmin Kalberer. All rights reserved.
//
//! An extension to rust-postgres, adds support for PostGIS.
//!
//! - PostGIS type helper
//! - GCJ02 support (used offically in Mainland China)
//! - Tiny WKB (TWKB) support
//!
//! ```rust,no_run
//! 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:
//!
//! ```rust,no_run
//! # use postgres::{Client, NoTls};
//! # use postgis::{ewkb, LineString};
//! # let mut client = Client::connect("host=localhost user=postgres", NoTls).unwrap();
//! # let rows = client.query("SELECT * FROM busline", &[]).unwrap();
//! # let row = rows.first().unwrap();
//! 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) }
//! }
//! ```
pub use ;