This commit is contained in:
Stepan Kuzmin 2018-01-31 12:59:44 +03:00
parent 8ad3fccd8a
commit 9a0e2442f0
3 changed files with 7 additions and 14 deletions

6
Cargo.lock generated
View File

@ -72,7 +72,7 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -211,7 +211,7 @@ dependencies = [
[[package]]
name = "iovec"
version = "0.1.1"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
@ -927,7 +927,7 @@ dependencies = [
"checksum httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f407128745b78abc95c0ffbe4e5d37427fdc0d45470710cfef8c44522a2e37"
"checksum hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)" = "368cb56b2740ebf4230520e2b90ebb0461e69034d85d1945febd9b3971426db2"
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
"checksum iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6e8b9c2247fcf6c6a1151f1156932be5606c9fd6f55a2d7f9fc1cb29386b2f7"
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
"checksum iron 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d8e17268922834707e1c29e8badbf9c712c9c43378e1b6a3388946baff10be2"
"checksum iron-test 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1944bcf30f8b3f51ebf01e715517dd9755e9480934778d6de70179a41d283c1"
"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c"

View File

@ -122,8 +122,9 @@ pub fn tile(req: &mut Request, caps: Captures) -> IronResult<Response> {
None => None
};
let tile = match tileset::get_tile(conn, &tileset, z, x, y, condition) {
Ok(tile) => tile,
let query = tileset.get_query(z.clone(), x.clone(), y.clone(), condition);
let tile: Vec<u8> = match conn.query(&query, &[]) {
Ok(rows) => rows.get(0).get("st_asmvt"),
Err(error) => {
error!("Couldn't get a tile: {}", error);
return Ok(Response::with((status::InternalServerError)));

View File

@ -69,7 +69,7 @@ impl Tileset {
condition.unwrap_or("".to_string())
);
// debug!("\n\n{}\n\n", query);
debug!("\n\n{}\n\n", query);
query
}
@ -135,11 +135,3 @@ pub fn get_tilesets(conn: PostgresConnection) -> Result<HashMap<String, Tileset>
Ok(tilesets)
}
pub fn get_tile<'a>(conn: PostgresConnection, tileset: &Tileset, z: &u32, x: &u32, y: &u32, condition: Option<String>) -> Result<Vec<u8>, Box<Error>> {
let query = tileset.get_query(z.clone(), x.clone(), y.clone(), condition);
let rows = try!(conn.query(&query, &[]));
let tile = rows.get(0).get("st_asmvt");
Ok(tile)
}