### Serving Vector Tiles with Configuration File Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Explains how to start the t-rex server using a previously generated configuration file instead of command-line options. This is useful for managing more complex settings. ```Shell t_rex serve --config osm2vectortiles.toml ``` -------------------------------- ### Installing Build Dependencies on Ubuntu Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Lists the necessary packages to install on Ubuntu 20.04 (Focal Fossa) to build the t-rex project from source. Requires root privileges to use `apt install`. ```Shell sudo apt install cargo libssl-dev libgdal-dev clang ``` -------------------------------- ### Setting up Test S3 Storage with MinIO and mc Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Provides a sequence of commands to start a MinIO Docker container, configure the MinIO client (`mc`) to connect to it, create a bucket named 'trex', and set its policy to allow public downloads. ```Shell docker run -d --rm -p 9000:9000 -e MINIO_REGION_NAME=my-region -e MINIO_ACCESS_KEY=miniostorage -e MINIO_SECRET_KEY=miniostorage minio/minio server /data && sleep 5 && mc config host add local-docker http://localhost:9000 miniostorage miniostorage && mc mb local-docker/trex && mc policy set download local-docker/trex ``` -------------------------------- ### Starting Test PostgreSQL Database with Docker Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Provides the Docker command to run a predefined `trextestdb` container, mapping port 5439 to 5432 inside the container, detaching, naming the container, and ensuring it's removed on exit. ```Shell docker run -p 127.0.0.1:5439:5432 -d --name trextestdb --rm sourcepole/trextestdb ``` -------------------------------- ### Serving Vector Tiles from PostgreSQL (Quick Tour) Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Demonstrates the basic command to start the t-rex server, connecting to a PostgreSQL database specified by a connection URL. The server will listen on localhost:6767 and serve tiles based on data found in the database. ```Shell t_rex serve --dbconn postgresql://user:pass@localhost/osm2vectortiles ``` -------------------------------- ### Configuring Database Connection Using Environment Variable (TOML/Tera) Source: https://github.com/t-rex-tileserver/t-rex/blob/master/CHANGELOG.md This example demonstrates how to set the database connection URL in a TOML configuration file by referencing an environment variable (`TREX_DATASOURCE_URL`) using Tera template syntax. This allows flexible deployment configurations. ```TOML dbconn = "{{ env.TREX_DATASOURCE_URL }}" ``` -------------------------------- ### Setting up Local Test Database Data Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Provides the sequence of commands to change directory to the 'data' folder and execute the 'make' command to create and load data into a local PostgreSQL test database. Assumes PostgreSQL environment variables are set. ```Shell cd data make createdb loaddata ``` -------------------------------- ### Running Server for Development via Cargo Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Demonstrates how to run the t-rex server executable directly using `cargo run`, specifying the `serve` subcommand and a database connection for development and testing purposes. ```Shell cargo run -- serve --dbconn postgresql://t_rex:t_rex@127.0.0.1:5439/t_rex_tests ``` -------------------------------- ### Generating Configuration Template Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Illustrates how to generate a default configuration file template from a database connection. The output is piped to `tee` to save it to a file while also displaying it on the console. ```Shell t_rex genconfig --dbconn postgresql://user:pass@localhost/osm2vectortiles | tee osm2vectortiles.toml ``` -------------------------------- ### Building the Rust Project Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Provides the standard Cargo command to build the t-rex project in debug mode. This compiles the source code and creates the executable. ```Shell cargo build ``` -------------------------------- ### Decoding a Vector Tile using curl and protoc Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Shows a command sequence to fetch a specific vector tile using `curl`, pipe its binary content, and decode it using `protoc` and the MVT protocol definition file. Requires `curl`, `protoc`, and the `vector_tile.proto` file. ```Shell curl --silent http://127.0.0.1:6767/ne_10m_populated_places/5/31/17.pbf | protoc --decode=vector_tile.Tile t-rex-core/src/mvt/vector_tile.proto ``` -------------------------------- ### Running All Unit Tests Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Shows the Cargo command to execute all unit tests defined within the project. Tests ensure the correct functionality of different components. ```Shell cargo test --all ``` -------------------------------- ### Generating Tiles for Cache from Configuration Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Shows the command to generate tiles for the cache based on the layers and extents defined in a configuration file. This is typically used to pre-populate the cache. ```Shell t_rex generate --config osm2vectortiles.toml ``` -------------------------------- ### Running All Tests including Ignored and All Features Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Shows the Cargo command to execute all unit tests, including those normally ignored (like DB and S3 tests), while enabling all features defined in the project's Cargo.toml. This is for comprehensive testing. ```Shell cargo test --all-features --all -- --ignored ``` -------------------------------- ### Serving Vector Tiles with File Cache Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Shows how to enable a file-based tile cache when serving vector tiles. The server will store generated tiles in the specified directory to improve performance on subsequent requests for the same tiles. ```Shell t_rex serve --dbconn postgresql://user:pass@localhost/osm2vectortiles --cache /tmp/mvtcache ``` -------------------------------- ### Serving Vector Tiles with Debug Log Level Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Demonstrates how to increase the verbosity of the server's logging output to 'debug'. This is helpful for troubleshooting issues by providing more detailed information about the server's operations. ```Shell t_rex serve --loglevel debug --dbconn postgresql://user:pass@localhost/osm2vectortiles ``` -------------------------------- ### Running Ignored Tests (including Database Tests) Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Explains how to execute unit tests that are ignored by default, specifically including those that depend on external services like a database. The `--ignored` flag tells Cargo to run only ignored tests. ```Shell cargo test --all -- --ignored ``` -------------------------------- ### Setting Database Connection Environment Variable for Tests Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Instructs how to set the `DBCONN` environment variable with the connection string for the test database. This variable is used by ignored unit tests that require a database connection. ```Shell export DBCONN=postgresql://t_rex:t_rex@127.0.0.1:5439/t_rex_tests ``` -------------------------------- ### Setting S3 Test Environment Variable Source: https://github.com/t-rex-tileserver/t-rex/blob/master/README.md Instructs how to set the `S3TEST` environment variable. This variable signals to the test suite that an S3 compatible service is available for running S3-specific tests. ```Shell export S3TEST=true ``` -------------------------------- ### Accessing Environment Variables with Tera Templates Source: https://github.com/t-rex-tileserver/t-rex/blob/master/CHANGELOG.md This snippet shows the syntax for accessing environment variables within a configuration file using the Tera templating engine. It replaces the older `${VARNAME}` syntax. Use this to dynamically set configuration values based on the environment. ```Tera {{env.VARNAME}} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.