Skip to content

Commit

Permalink
Merge pull request #2 from stadiamaps/sqlx-0-5
Browse files Browse the repository at this point in the history
Upgrade to sqlx 0.5
  • Loading branch information
lseelenbinder committed Feb 18, 2021
2 parents 1eb723b + 9755125 commit d935e21
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tile_sorcerer"
version = "0.2.0"
version = "0.3.0"
authors = ["Ian Wagner <[email protected]>", "Luke Seelenbinder <[email protected]>"]
license = "BSD-3-Clause"
repository = "https://github.com/stadiamaps/tile_sorcerer"
Expand All @@ -22,9 +22,9 @@ version = "~1.0"
features = ["derive"]

[dependencies.sqlx]
version = "~0.3"
version = "~0.5"
default-features = false
features = ["runtime-tokio", "postgres", "chrono", "uuid"]
features = ["runtime-tokio-rustls", "postgres", "chrono", "uuid", "tls"]

[dev-dependencies]
assert_approx_eq = "~1.1"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Tools for modeling and querying vector tile sources.

## Current status

This code should be regarded as stable beta. While there are a number of
This crate should be regarded as stable in terms of code correctness, but not
yet stable in terms of trait and method signatures and feature set. While there are a number of
known limitations, this code is being deployed at scale already. We are
releasing this code in Rust tradition as 0.x until we feel the interface
and feature set have stabilized, but welcome usage and contributions from
Expand Down
28 changes: 27 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
//! # Tile Sorcerer
//!
//! This crate provides tools for modeling and querying vector tile sources.
//! Tools for modeling and querying vector tile sources.
//!
//! ## Current status
//!
//! This crate should be regarded as stable in terms of code reliability/correctness, but not
//! yet stable in terms of trait and method signatures. While there are a number of
//! known limitations, this code is being deployed at scale already. We are
//! releasing this code in Rust tradition as 0.x until we feel the interface
//! and feature set have stabilized, but welcome usage and contributions from
//! the Rust GIS community.
//!
//! ## Current features
//!
//! Given a PostGIS database and a TileMill source (such as OpenMapTiles data),
//! this crate will help you leverage PostGIS to render Mapbox Vector Tiles.
//!
//! ## Known Limitations
//!
//! The current focus is on high-performance rendering from a single PostGIS database.
//! Other formats are not presently supported, but can be added in the future.
//! As such, the database connection info present in layers is presently ignored, and
//! it is up to the calling application to set up a connection pool pointed at the right
//! database. Projection info is also currently ignored, and your database is assumed to be
//! in EPSG:3857 web mercator already.
//!
//! The trait-based design allows for further extensibility, so additional operations,
//! tile source formats, etc. will likely be added in the future.

#![deny(warnings)]

Expand Down
18 changes: 11 additions & 7 deletions src/tm2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// TileMill Layer Source YAML Format
///
/// Further reading: https://tilemill-project.github.io/tilemill/docs/manual/adding-layers/
//! Data models and trait implementations for TileMill 2 yaml sources.
//!
//! Further reading: https://tilemill-project.github.io/tilemill/docs/manual/adding-layers/

use crate::{get_epsg_3857_tile_bounds, TileSource};

use std::collections::HashMap;
Expand All @@ -10,9 +11,9 @@ use serde::Deserialize;
// TODO: remove once async fn in traits become stable
use async_trait::async_trait;

use sqlx::{cursor::Cursor, query, PgPool, Row};
use sqlx::{query, PgPool, Row};

/// A TileMill (.tm2source) data structure.
/// The TileMill (.tm2source) data source model.
///
/// Note: The current data structure is not entirely complete. See the
/// crate README for limitations.
Expand All @@ -31,6 +32,7 @@ pub struct TM2Source {
pub bounds: [f64; 4],
}

/// A single layer of a TM2Source
#[derive(Clone, Deserialize, Debug)]
pub struct DataLayer {
pub id: String,
Expand All @@ -40,12 +42,14 @@ pub struct DataLayer {
// TODO: srs
}

/// A `DataLayer`'s source details
#[derive(Clone, Deserialize, Debug)]
pub struct LayerSource {
pub table: String,
// TODO: Database connection parameters
}

/// Additional properties of a `DataLayer`
#[derive(Clone, Deserialize, Debug)]
pub struct DataLayerProperties {
#[serde(rename = "buffer-size")]
Expand Down Expand Up @@ -150,8 +154,8 @@ impl TileSource for TM2Source {
});

let mut raw_tile: Vec<u8> = Vec::new();
let mut stream = query.fetch(&mut conn);
while let Some(row) = stream.next().await? {
let results = query.fetch_all(&mut conn).await?;
for row in results {
let layer: Vec<u8> = row.get(0);
raw_tile.extend_from_slice(&layer);
}
Expand Down

0 comments on commit d935e21

Please sign in to comment.