diff --git a/Cargo.lock b/Cargo.lock index 80146b4f..83cff722 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -968,9 +968,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "jobserver" @@ -1047,7 +1047,7 @@ dependencies = [ [[package]] name = "martin" -version = "1.0.0-alpha.0" +version = "0.6.0" dependencies = [ "actix", "actix-cors", @@ -1195,6 +1195,15 @@ dependencies = [ "syn", ] +[[package]] +name = "openssl-src" +version = "111.22.0+1.1.1q" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f31f0d509d1c1ae9cada2f9539ff8f37933831fd5098879e482aa687d659853" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.76" @@ -1204,6 +1213,7 @@ dependencies = [ "autocfg", "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -1711,9 +1721,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.101" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" +checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" dependencies = [ "proc-macro2", "quote", @@ -1859,9 +1869,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.36" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", @@ -1871,9 +1881,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.29" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" dependencies = [ "once_cell", ] diff --git a/Cargo.toml b/Cargo.toml index cb8a1899..c3ae171e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "martin" -version = "1.0.0-alpha.0" +version = "0.6.0-rc.1" edition = "2021" -authors = ["Stepan Kuzmin ", "MapLibre contributors"] -description = "Blazing fast and lightweight PostGIS vector tiles server" -repository = "https://github.com/maplibre/martin/" +authors = ["Stepan Kuzmin ", "Yuri Astrakhan ", "MapLibre contributors"] +description = "Blazing fast and lightweight PostGIS vector tile server" +repository = "https://github.com/maplibre/martin" license = "MIT OR Apache-2.0" [lib] diff --git a/README.md b/README.md index b9d61185..1976b444 100755 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Martin is a [PostGIS](https://github.com/postgis/postgis) [vector tiles](https:/ - [Installation](#installation) - [Usage](#usage) - [API](#api) -- [Using with Mapbox GL JS](#using-with-mapbox-gl-js) +- [Using with MapLibre GL JS](#using-with-maplibre) - [Using with Leaflet](#using-with-leaflet) - [Using with deck.gl](#using-with-deckgl) - [Table Sources](#table-sources) @@ -98,14 +98,11 @@ When started, martin will go through all spatial tables and functions with an ap | `GET` | `/rpc/{schema_name}.{function_name}/{z}/{x}/{y}.pbf` | [Function Source Tiles](#function-source-tiles) | | `GET` | `/healthz` | Martin server health check: returns `200 OK` | -## Using with Mapbox GL JS +## Using with MapLibre +[MapLibre](https://maplibre.org/projects/maplibre-gl-js/) is an Open-source JavaScript library for showing maps on a website. MapLibre can accept [MVT vector tiles](https://github.com/mapbox/vector-tile-spec) generated by Martin, and applies [a style](https://maplibre.org/maplibre-gl-js-docs/style-spec/) to them to draw a map using Web GL. -[Mapbox GL JS](https://github.com/mapbox/mapbox-gl-js) is a JavaScript library for interactive, customizable vector maps on the web. It takes map styles that conform to the -[Mapbox Style Specification](https://www.mapbox.com/mapbox-gl-js/style-spec), applies them to vector tiles that -conform to the [Mapbox Vector Tile Specification](https://github.com/mapbox/vector-tile-spec), and renders them using -WebGL. +You can add a layer to the map and specify Martin [TileJSON](https://github.com/mapbox/tilejson-spec) endpoint as a vector source URL. You should also specify a `source-layer` property. For [Table Sources](#table-sources) it is `{schema_name}.{table_name}` by default. -You can add a layer to the map and specify martin TileJSON endpoint as a vector source URL. You should also specify a `source-layer` property. For [Table Sources](#table-sources) it is `{schema_name}.{table_name}` by default. ```js map.addLayer({ @@ -118,7 +115,23 @@ map.addLayer({ 'source-layer': 'public.points', paint: { 'circle-color': 'red' - } + }, +}); +``` + +```js +map.addSource('rpc', { + type: 'vector', + url: `http://localhost:3000/rpc/public.function_source.json` +}); +map.addLayer({ + id: 'points', + type: 'circle', + source: 'rpc', + 'source-layer': 'public.function_source', + paint: { + 'circle-color': 'blue' + }, }); ``` @@ -151,26 +164,6 @@ map.addLayer({ }); ``` -## Using with MapLibre -[MapLibre](https://maplibre.org/projects/maplibre-gl-js/) is an Open-source JavaScript library for publishing maps on your websites. Originated as an open-source fork of [mapbox-gl-js](https://www.mapbox.com/mapbox-gljs), [MapLibre](https://maplibre.org/projects/maplibre-gl-js/) is intended to be a drop-in replacement for the Mapbox’s version with additional functionality. -Generally There is no big difference between MapLibre and [mapbox-gl-js](https://www.mapbox.com/mapbox-gljs) when cooperating with Martin. - -```js -map.addSource('rpc', { - type: 'vector', - url: `http://localhost:3000/rpc/public.function_source.json` -}); -map.addLayer({ - id: 'points', - type: 'circle', - source: 'rpc', - 'source-layer': 'public.function_source', - paint: { - 'circle-color': 'blue' - } -}); -``` - ## Using with Leaflet [Leaflet](https://github.com/Leaflet/Leaflet) is the leading open-source JavaScript library for mobile-friendly interactive maps. @@ -220,6 +213,27 @@ const deckgl = new DeckGL({ }); ``` +## Using with Mapbox + +[Mapbox GL JS](https://github.com/mapbox/mapbox-gl-js) is a JavaScript library for interactive, customizable vector maps on the web. Mapbox GL JS v1.x was open source, and it was forked as MapLibre (see [above](#using-with-maplibre)), so using Martin with Mapbox is similar to MapLibre. Mapbox GL JS can accept [MVT vector tiles](https://github.com/mapbox/vector-tile-spec) generated by Martin, and applies [a style](https://docs.mapbox.com/mapbox-gl-js/style-spec/) to them to draw a map using Web GL. + +You can add a layer to the map and specify martin TileJSON endpoint as a vector source URL. You should also specify a `source-layer` property. For [Table Sources](#table-sources) it is `{schema_name}.{table_name}` by default. + +```js +map.addLayer({ + id: 'public.points', + type: 'circle', + source: { + type: 'vector', + url: 'http://localhost:3000/public.points.json' + }, + 'source-layer': 'public.points', + paint: { + 'circle-color': 'red' + } +}); +``` + ## Table Sources Table Source is a database table which can be used to query [vector tiles](https://github.com/mapbox/vector-tile-spec). When started, martin will go through all spatial tables in the database and build a list of table sources. A table should have at least one geometry column with non-zero SRID. All other table columns will be represented as properties of a vector tile feature. @@ -387,22 +401,32 @@ curl localhost:3000/rpc/public.points/0/0/0.pbf You can configure martin using command-line interface ```shell -Usage: - martin [options] [] - martin -h | --help - martin -v | --version +Usage: martin [OPTIONS] [CONNECTION] + +Arguments: + [CONNECTION] Database connection string Options: - -h --help Show this screen. - -v --version Show version. - --config= Path to config file. - --keep-alive= Connection keep alive timeout [default: 75]. - --listen-addresses= The socket address to bind [default: 0.0.0.0:3000]. - --default-srid= If a spatial table has SRID 0, then this default SRID will be used as a fallback. - --pool-size= Maximum connections pool size [default: 20]. - --workers= Number of web server workers. - --ca-root-file= Loads trusted root certificates from a file. The file should contain a sequence of PEM-formatted CA certificates. - --danger-accept-invalid-certs Trust invalid certificates. This introduces significant vulnerabilities, and should only be used as a last resort. + -c, --config + Path to config file + -k, --keep-alive + Connection keep alive timeout. [DEFAULT: 75] + -l, --listen-addresses + The socket address to bind. [DEFAULT: 0.0.0.0:3000] + -W, --workers + Number of web server workers + --ca-root-file + Loads trusted root certificates from a file. The file should contain a sequence of PEM-formatted CA certificates + --danger-accept-invalid-certs + Trust invalid certificates. This introduces significant vulnerabilities, and should only be used as a last resort + -d, --default-srid + If a spatial table has SRID 0, then this default SRID will be used as a fallback + -p, --pool-size + Maximum connections pool size [DEFAULT: 20] + -h, --help + Print help information + -V, --version + Print version information ``` ## Environment Variables diff --git a/src/bin/main.rs b/src/bin/main.rs index 26bbbe8c..ff5c3a77 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -12,6 +12,7 @@ const VERSION: &str = env!("CARGO_PKG_VERSION"); #[derive(Parser, Debug)] #[command(about, version)] +#[clap(disable_colored_help = false)] pub struct Args { /// Database connection string pub connection: Option,