Basic Go server for mbtiles

Overview

mbtileserver

A simple Go-based server for map tiles stored in mbtiles format.

Build Status Coverage Status GoDoc Go Report Card

It currently provides support for png, jpg, and pbf (vector tile) tilesets according to version 1.0 of the mbtiles specification. Tiles are served following the XYZ tile scheme, based on the Web Mercator coordinate reference system. UTF8 Grids are also supported.

In addition to tile-level access, it provides:

  • TileJSON 2.1.0 endpoint for each tileset, with full metadata from the mbtiles file.
  • a preview map for exploring each tileset.
  • a minimal ArcGIS tile map service API

We have been able to host a bunch of tilesets on an AWS t2.nano virtual machine without any issues.

Goals

  • Provide a web tile API for map tiles stored in mbtiles format
  • Be fast
  • Run on small resource cloud hosted machines (limited memory & CPU)
  • Be easy to install and operate

Supported Go versions

Requires Go 1.10+. Go 1.13 is recommended for full support.

mbtileserver uses go modules and follows standard practices as of Go 1.13.

Due to varying degrees of go module support between Go versions 1.10 and 1.13, we provide a vendor directory with dependencies for older versions. This is deprecated and will be removed in an upcoming version.

Note: Go versions 1.11.0 - 1.11.3 are not supported, use Go 1.11.4. This is due to differences in how those versions handled go modules (see).

Installation

You can install this project with

go get github.com/consbio/mbtileserver

This will create and install an executable called mbtileserver.

Usage

From within the repository root ($GOPATH/bin needs to be in your $PATH):

$  mbtileserver --help
Serve tiles from mbtiles files.

Usage:
  mbtileserver [flags]

Flags:
  -c, --cert string            X.509 TLS certificate filename.  If present, will be used to enable SSL on the server.
  -d, --dir string             Directory containing mbtiles files. Directory containing mbtiles files.  Can be a comma-delimited list of directories. (default "./tilesets")
      --disable-preview        Disable map preview for each tileset (enabled by default)
      --disable-svc-list       Disable services list endpoint (enabled by default)
      --disable-tilejson       Disable TileJSON endpoint for each tileset (enabled by default)
      --domain string          Domain name of this server.  NOTE: only used for AutoTLS.
      --dsn string             Sentry DSN
      --enable-arcgis          Enable ArcGIS Mapserver endpoints
      --enable-reload-signal   Enable graceful reload using HUP signal to the server process
      --generate-ids           Automatically generate tileset IDs instead of using relative path
  -h, --help                   help for mbtileserver
  -k, --key string             TLS private key
  -p, --port int               Server port. Default is 443 if --cert or --tls options are used, otherwise 8000. (default -1)
  -r, --redirect               Redirect HTTP to HTTPS
      --root-url string        Root URL of services endpoint (default "/services")
  -s, --secret-key string      Shared secret key used for HMAC request authentication
      --tiles-only             Only enable tile endpoints (shortcut for --disable-svc-list --disable-tilejson --disable-preview)
  -t, --tls                    Auto TLS via Let's Encrypt
  -v, --verbose                Verbose logging

So hosting tiles is as easy as putting your mbtiles files in the tilesets directory and starting the server. Woo hoo!

You can have multiple directories in your tilesets directory; these will be converted into appropriate URLs:

<tile_dir>/foo/bar/baz.mbtiles will be available at /services/foo/bar/baz.

If --generate-ids is provided, tileset IDs are automatically generated using a SHA1 hash of the path to each tileset. By default, tileset IDs are based on the relative path of each tileset to the base directory provided using --dir.

When you want to remove, modify, or add new tilesets, simply restart the server process or use the reloading process below.

If a valid Sentry DSN is provided, warnings, errors, fatal errors, and panics will be reported to Sentry.

If redirect option is provided, the server also listens on port 80 and redirects to port 443.

If the --tls option is provided, the Let's Encrypt Terms of Service are accepted automatically on your behalf. Please review them here. Certificates are cached in a .certs folder created where you are executing mbtileserver. Please make sure this folder can be written by the mbtileserver process or you will get errors. Certificates are not requested until the first request is made to the server. We recommend that you initialize these after startup by making a request against https://<hostname>/services and watching the logs from the server to make sure that certificates were processed correctly. Common errors include Let's Encrypt not being able to access your server at the domain you provided. localhost or internal-only domains will not work.

If either --cert or --tls are provided, the default port is 443.

You can also use environment variables instead of flags, which may be more helpful when deploying in a docker image. Use the associated flag to determine usage. The following variables are available:

  • PORT (--port)
  • TILE_DIR (--dir)
  • GENERATE_IDS (--generate-ids)
  • ROOT_URL_PATH (--root-url-path)
  • DOMAIN (--domain)
  • TLS_CERT (--cert)
  • TLS_PRIVATE_KEY (--key)
  • HMAC_SECRET_KEY (--secret-key)
  • AUTO_TLS (--tls)
  • REDIRECT (--redirect)
  • DSN (--dsn)
  • VERBOSE (--verbose)

Example:

$ PORT=7777 TILE_DIR=./path/to/your/tiles VERBOSE=true mbtileserver

In a docker-compose.yml file it will look like:

mbtileserver:
  ...

  environment:
    PORT: 7777
    TILE_DIR: "./path/to/your/tiles"
    VERBOSE: true
  entrypoint: mbtileserver

  ...

Reload

mbtileserver optionally supports graceful reload (without interrupting any in-progress requests). This functionality must be enabled with the --enable-reload-signal flag. When enabled, the server can be reloaded by sending it a HUP signal:

$ kill -HUP <pid>

Reloading the server will cause it to pick up changes to the tiles directory, adding new tilesets and removing any that are no longer present.

Using with a reverse proxy

You can use a reverse proxy in front of mbtileserver to intercept incoming requests, provide TLS, etc.

We have used both Caddy and NGINX for our production setups in various projects, usually when we need to proxy to additional backend services.

To make sure that the correct request URL is passed to mbtileserver so that TileJSON and map preview endpoints work correctly, make sure to have your reverse proxy send the following headers:

Scheme (HTTP vs HTTPS): one of X-Forwarded-Proto, X-Forwarded-Protocol, X-Url-Scheme to set the scheme of the request. OR X-Forwarded-Ssl to automatically set the scheme to HTTPS.

Host: Set Host and X-Forwarded-Host.

Caddy Example:

For mbtileserver running on port 8000 locally, add the following to the block for your domain name:

<domain_name> {
    proxy /services localhost:8000 {
        transparent
    }
}

Using transparent preset for the proxy settings instructs Caddy to automatically set appropriate headers.

NGINX Example:

For mbtileserver running on port 8000 locally, add the following to your server block:

server {
   <other config options>

    location /services {
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://localhost:8000;
    }
}

Docker

Pull the latest image from Docker Hub:

docker pull consbio/mbtileserver:latest

To build the Docker image locally (named mbtileserver):

docker build -t mbtileserver -f Dockerfile .

To run the Docker container on port 8080 with your tilesets in <host tile dir>. Note that by default, mbtileserver runs on port 8000 in the container.

docker run --rm -p 8080:8000 -v <host tile dir>:/tilesets  consbio/mbtileserver

You can pass in additional command-line arguments to mbtileserver, for example, to use certificates and files in <host cert dir> so that you can access the server via HTTPS. The example below uses self-signed certificates generated using mkcert. This example uses automatic redirects, which causes mbtileserver to also listen on port 80 and automatically redirect to 443.

docker run  --rm -p 80:80 443:443 -v <host tile dir>:/tilesets -v <host cert dir>:/certs/ consbio/mbtileserver -c /certs/localhost.pem -k /certs/localhost-key.pem -p 443 --redirect

Alternately, use docker-compose to run:

docker-compose up -d

The default docker-compose.yml configures mbtileserver to connect to port 8080 on the host, and uses the ./mbtiles/testdata folder for tilesets. You can use your own docker-compose.override.yml or environment specific files to set these how you like.

To reload the server:

docker exec -it mbtileserver sh -c "kill -HUP 1"

Specifications

Creating Tiles

You can create mbtiles files using a variety of tools. We have created tiles for use with mbtileserver using:

The root name of each mbtiles file becomes the "tileset_id" as used below.

XYZ Tile API

The primary use of mbtileserver is as a host for XYZ tiles.

These are provided at: /services/<tileset_id>/tiles/{z}/{x}/{y}.<format>

where <format> is one of png, jpg, pbf depending on the type of data in the tileset.

If UTF-8 Grid data are present in the mbtiles file, they will be served up over the grid endpoint: http://localhost/services/states_outline/tiles/{z}/{x}/{y}.json

Grids are assumed to be gzip or zlib compressed in the mbtiles file. These grids are automatically spliced with any grid key/value data if such exists in the mbtiles file.

TileJSON API

mbtileserver automatically creates a TileJSON endpoint for each service at /services/<tileset_id>. The TileJSON uses the same scheme and domain name as is used for the incoming request; the --domain setting does not affect auto-generated URLs.

This API provides most elements of the metadata table in the mbtiles file as well as others that are automatically inferred from tile data.

For example, http://localhost/services/states_outline

returns something like this:

{
  "bounds": [
    -179.23108,
    -14.601813,
    179.85968,
    71.441055
  ],
  "center": [
    0.314297,
    28.419622,
    1
  ],
  "credits": "US Census Bureau",
  "description": "States",
  "format": "png",
  "id": "states_outline",
  "legend": "[{\"elements\": [{\"label\": \"\", \"imageData\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAGFJREFUOI3tlDEOgEAIBClI5kF+w0fxwXvQdjZywcZEtDI31YaQgWrdPsYzAPFGJCmmEAhJGzCash0wSVE/HHnlKcDMfrPXYgmXcAl/JswK6lCrz89BdGVm1+qrH0bbWDgA3WwmgzD8ueEAAAAASUVORK5CYII=\"}], \"name\": \"tl_2015_us_state\"}]",
  "map": "http://localhost/services/states_outline/map",
  "maxzoom": 4,
  "minzoom": 0,
  "name": "states_outline",
  "scheme": "xyz",
  "tags": "states",
  "tilejson": "2.1.0",
  "tiles": [
    "http://localhost/services/states_outline/tiles/{z}/{x}/{y}.png"
  ],
  "type": "overlay",
  "version": "1.0.0"
}

Map preview

mbtileserver automatically creates a map preview page for each tileset at /services/<tileset_id>/map.

This currently uses Leaflet for image tiles and Mapbox GL JS for vector tiles.

ArcGIS API

This project currently provides a minimal ArcGIS tiled map service API for tiles stored in an mbtiles file.

This is enabled with the --enable-arcgis flag.

This should be sufficient for use with online platforms such as Data Basin. Because the ArcGIS API relies on a number of properties that are not commonly available within an mbtiles file, so certain aspects are stubbed out with minimal information.

This API is not intended for use with more full-featured ArcGIS applications such as ArcGIS Desktop.

Available endpoints:

  • Service info: http://localhost:8000/arcgis/rest/services/<tileset_id>/MapServer
  • Layer info: http://localhost:8000/arcgis/rest/services/<tileset_id>/MapServer/layers
  • Tiles: http://localhost:8000/arcgis/rest/services/<tileset_id>/MapServer/tile/0/0/0

Request authorization

Providing a secret key with -s/--secret-key or by setting the HMAC_SECRET_KEY environment variable will restrict access to all server endpoints and tile requests. Requests will only be served if they provide a cryptographic signature created using the same secret key. This allows, for example, an application server to provide authorized clients a short-lived token with which the clients can access tiles for a specific service.

Signatures expire 15 minutes from their creation date to prevent exposed or leaked signatures from being useful past a small time window.

Creating signatures

A signature is a URL-safe, base64 encoded HMAC hash using the SHA1 algorithm. The hash key is an SHA1 key created from a randomly generated salt, and the secret key string. The hash payload is a combination of the ISO-formatted date when the hash was created, and the authorized service id.

The following is an example signature, created in Go for the service id test, the date 2019-03-08T19:31:12.213831+00:00, the salt 0EvkK316T-sBLA, and the secret key YMIVXikJWAiiR3q-JMz1v2Mfmx3gTXJVNqme5kyaqrY

Create the SHA1 key:

serviceId := "test"
date := "2019-03-08T19:31:12.213831+00:00"
salt := "0EvkK316T-sBLA"
secretKey := "YMIVXikJWAiiR3q-JMz1v2Mfmx3gTXJVNqme5kyaqrY"

key := sha1.New()
key.Write([]byte(salt + secretKey))

Create the signature hash:

hash := hmac.New(sha1.New, key.Sum(nil))
message := fmt.Sprintf("%s:%s", date, serviceId)
hash.Write([]byte(message))

Finally, base64-encode the hash:

b64hash := base64.RawURLEncoding.EncodeToString(hash.Sum(nil))
fmt.Println(b64hash) // Should output: 2y8vHb9xK6RSxN8EXMeAEUiYtZk

Making request

Authenticated requests must include the ISO-fromatted date, and a salt-signature combination in the form of: <salt>:<signature>. These can be provided as query parameters:

?date=2019-03-08T19:31:12.213831%2B00:00&signature=0EvkK316T-sBLA:YMIVXikJWAiiR3q-JMz1v2Mfmx3gTXJVNqme5kyaqrY

Or they can be provided as request headers:

X-Signature-Date: 2019-03-08T19:31:12.213831+00:00
X-Signature: 0EvkK316T-sBLA:YMIVXikJWAiiR3q-JMz1v2Mfmx3gTXJVNqme5kyaqrY

Development

Dependencies are managed using go modules. Vendored dependencies are stored in vendor folder by using go mod vendor.

On Windows, it is necessary to install gcc in order to compile mattn/go-sqlite3. MinGW or TDM-GCC should work fine.

If you experience very slow builds each time, it may be that you need to first run

go build -a .

to make subsequent builds much faster.

Development of the templates and static assets likely requires using node and npm. Install these tools in the normal way.

From the handlers/templates/static folder, run

$npm install

to pull in the static dependencies. These are referenced in the package.json file.

Then to build the minified version, run:

$gulp build

Modifying the .go files always requires re-running go build ..

In case you have modified the templates and static assets, you need to run go generate ./handlers/templates.go to ensure that your modifications are embedded into the executable. For this to work, you must have [github.com/shurcooL/vfsgen)[https://github.com/shurcooL/vfsgen) installed.

go generate ./handlers/templates.go

This will rewrite the assets_vfsdata.go which you must commit along with your modification. You should run go build after go generate.

During the development cycle you may use go build -tags dev . to build the binary, in which case it will always take the assets from the relative file path handlers/templates/ directly and you can omit the go generate step. (note: this is currently not working properly) But do not forget to perform it in the end.

Changes

See CHANGELOG.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Brendan Ward
Brendan Ward

πŸ’» πŸ“– πŸ› πŸ“ πŸ‘€ πŸ€”
Fabian Wickborn
Fabian Wickborn

πŸ’» πŸ“– πŸ› πŸ€”
Nik Molnar
Nik Molnar

πŸ’» πŸ€” πŸ›
Nikolay Korotkiy
Nikolay Korotkiy

πŸ’» πŸ›
Robert Brown
Robert Brown

πŸ’»
Mihail
Mihail

πŸ’»
Marko Burjek
Marko Burjek

πŸ’»
Kristjan
Kristjan

πŸ’»
evbarnett
evbarnett

πŸ›
walkaholic.me
walkaholic.me

πŸ›
Brian Voelker
Brian Voelker

πŸ›
Georg Leciejewski
Georg Leciejewski

πŸ›

This project follows the all-contributors specification. Contributions of any kind welcome!

Comments
  • Too large memory usage in last version

    Too large memory usage in last version

    Hi! I'm use cgroups memory limitations from docker-compose.yml

      mbtiles:
        image: mbtiles
        environment:
          - TILE_DIR=/external,/internal
          - PORT=80
        networks:
          phoenix:
            ipv4_address: 172.18.0.21
        read_only: True
        restart: always
        volumes: ['/opt/mbtiles/:/internal', '/opt/usb/mbtiles/:/external']
        logging:
          driver: "none"
        deploy:
          restart_policy:
            condition: any
          resources:
            limits:
              memory: 30M
    

    Limit 30M not exceed in older version. But last version (https://github.com/consbio/mbtileserver/commit/ca4a94e0c5a4487c64d271e6d1428a6aefcd094c) want about 1G of memory without limitation =( This is a critical for single-board computers... Log:

    mbtiles_1               | time="2020-05-20T15:45:59Z" level=info msg="Searching for tilesets in /external\n"
    mbtiles_1               | time="2020-05-20T15:45:59Z" level=info msg="Searching for tilesets in /internal\n"
    mbtiles_1               | time="2020-05-20T15:46:01Z" level=info msg="Searching for tilesets in /external\n"
    mbtiles_1               | time="2020-05-20T15:46:01Z" level=info msg="Searching for tilesets in /internal\n"
    docker_mbtiles_1 exited with code 137
    mbtiles_1               | time="2020-05-20T15:46:04Z" level=info msg="Searching for tilesets in /external\n"
    mbtiles_1               | time="2020-05-20T15:46:04Z" level=info msg="Searching for tilesets in /internal\n"
    

    internal and external paths contains big mbtiles files:

    [email protected]:/etc/docker# du -sh /opt/mbtiles/*
    9,2M    /opt/mbtiles/countries-raster.mbtiles
    18G     /opt/mbtiles/world_yandex.mbtiles
    [email protected]:/etc/docker# du -sh /opt/usb/mbtiles/*
    52G     /opt/usb/mbtiles/osm-2017-07-03-v3.6.1-planet.mbtiles
    
    opened by asmyasnikov 35
  • mbtileserver does not start on Windows

    mbtileserver does not start on Windows

    Following the instructions:

    You can install this project with
    
    go get github.com/consbio/mbtileserver
    
    This will create and install an executable called mbtileserver.
    

    However, the command does not install anything. Running it with -v only gives:

    C:\>go get -v github.com/consbio/mbtileserver
    github.com/consbio/mbtileserver (download)
    

    Thank you for your help

    opened by evbarnett 13
  • Refactor into two packages

    Refactor into two packages

    This is with regard to https://github.com/maputnik/editor/issues/184:

    /cc @lukasmartinelli

    I'd like to propose to refactor this repository so that it consists of main package and a non-mainpackage so that the tile server can be vendored and used in other Go projects.

    I'd be happy to contribute to the necessary effort if @consbio and @brendan-ward are interested.

    opened by fawick 12
  • Consider alternative basemap tile providers

    Consider alternative basemap tile providers

    See https://gist.github.com/reyemtm/0b57ca5e6535d3f2fe274442a17a782a for an example of the OSM data served by Esri in the Toner style. I also have an OSM basemap style.

    opened by reyemtm 7
  • BUG: Map preview fails when 'center' property is not present in metadata

    BUG: Map preview fails when 'center' property is not present in metadata

    I am not able to view the map. Every time I try (using Docker, installing with go get, or re-compiling from scratch) I get a blank page and this error in the browser's console:

    Uncaught TypeError: tileJSON.center is undefined
        <anonymous> http://localhost:8080/services/mymap/map:112
    

    Error is in both Edge (Chromium) and Firefox.

    bug 
    opened by ItalyPaleAle 7
  • Add ARM go release binaries

    Add ARM go release binaries

    Hi, I created this release workflow as I found it useful when using the new ARM-based Graviton instances on AWS (https://aws.amazon.com/ec2/graviton/). I was using a t4g.micro instance and ran into the out of memory error when trying to build the go binaries from source. I suppose this would also potentially be useful for people using raspberry pi's as well. Best, -Brandon

    opened by taylbm 6
  • Refactor of handlers, middleware, command line options

    Refactor of handlers, middleware, command line options

    Resolves #82, #94. Supersedes #99. Progress toward #78.

    Overview

    This version involved a significant refactor of internal functionality and HTTP handlers to provide better ability to modify services at runtime, provide granular control over the endpoints that are exposed, and cleanup handling of middleware.

    Most internal HTTP handlers for ServiceSet and Tileset in the github.com/consbio/mbtileserver/handlers package are now http.HandlerFuncs instead of custom handlers that returned status codes or errors as in the previous versions.

    The internal routing within these handlers has been modified to enable tilesets to change at runtime. Previously, we were using an http.ServeMux for all routes, which breaks when the Tileset instances pointed to by those routes have changed at runtime. Now, the top-level ServiceSet.Handler() allows dynamic routing to any Tileset instances currently published. Each Tileset is now responsible for routing to its subpaths (e.g., tile endpoint).

    The singular public handler endpoint is still an http.Handler instance but no longer takes any parameters. Those parameters are now handled using configuration options instead.

    ServiceSet now enables configuration to set the root URL, toggle which endpoints are exposed and set the internal error logger. These are passed in using a ServiceSetConfig struct when the service is constructed; these configuration options are not modifiable at runtime.

    Tileset instances are now created individually from a set of source mbtiles files, instead of generated within ServiceSet from a directory. This provides more granular control over assigning IDs to tilesets as well as creating, updating, or deleting Tileset instances. You must generate unique IDs for tilesets before adding to the ServiceSet; you can use handlers.SHA1ID(filename) to generate a unique SHA1 ID of the service based on its full filename path, or handlers.RelativePathID(filename, tilePath) to generate the ID from its path and filename within the tile directory tilePath.

    HMAC authorization has been refactored into middleware external to the Go API. It now is instantiated as middleware in main.go; this provides better separation of concerns between the server (main.go) and the Go API. The API for interacting with HMAC authorization from the CLI or endpoints remains the same.

    Most of the updates are demonstrated in main.go.

    General changes

    Command-line interface

    • added support for automatically generating unique tileset IDs using --generate-ids option

    • added ability to toggle off non-tile endpoints:

      • --disable-preview: disables the map preview, enabled by default.
      • --disable-svc-list: disables the list of map services, enabled by default
      • --disable-tilejson: disables the TileJSON endpoint for each tile service
      • --tiles-only: shortcut that disables preview, service list, and TileJSON endpoints
    • moved static assets for map preview that were originally served on /static endpoint to /services/<tileset_id>/map/static so that this endpoint is disabled when preview is disabled via --disable-preview.

    Go API

    • added ServiceSetConfig for configuration options for ServiceSet instances
    • added ServiceSet.AddTileset(), ServiceSet.UpdateTileset(), ServiceSet.RemoveTileset(), and ServiceSet.HasTileset() functions. WARNING: these functions are not yet thread-safe.

    Breaking changes

    Command-line interface:

    • ArcGIS endpoints are now opt-in via --enable-arcgis option (disabled by default)
    • --path option has been renamed to --root-url for clarity (env var is now ROOT_URL)
    • --enable-reload has been renamed to --enable-reload-signal

    Handlers API

    • ServiceSet.Handler parameters have been replaced with ServiceSetConfig passed to handlers.New() instead.
    • removed handlers.NewFromBaseDir(), replaced with handlers.New() and calling ServiceSet.AddTileset() for each Tileset to register.
    • removed ServiceSet.AddDBOnPath(); this is replaced by calling ServiceSet.AddTileset() for each Tileset to register.

    @nikmolnar this renames --enable-reload to --enable-reload-signal without deprecation period (the CHANGELOG should suffice to warn for deprecated uncommon command line options / name changes). Any concerns with that?

    @nikmolnar this changeset also moves HMAC auth middleware from inside every handler, and consolidates into a middleware layer that is external to them; it wraps the base handler within the chain of echo middleware at the server rather than handler level. This was to get us better separation of concerns; the server needs to manage auth via command line options, but the individual handlers should not need to be concerned with auth. From my testing, HMAC auth continued to work properly as expected.

    opened by brendan-ward 6
  • Domain flag doesn't change Tile JSON

    Domain flag doesn't change Tile JSON

    Passing --domain doesn't seem to change the domain urls for me. Am I doing something wrong? I'd expect the urls to be changed to http://example.com/services/....

    To reproduce:

    mbtileserver -d mbtiles -p 8891 --domain "example.com"
    
    > curl localhost:8891/services/ | jq '.'
    [
      {
        "imageType": "pbf",
        "url": "http://localhost:8891/services/california"
      },
      {
        "imageType": "pbf",
        "url": "http://localhost:8891/services/colorado"
      },
      {
        "imageType": "pbf",
        "url": "http://localhost:8891/services/new-mexico"
      },
      {
        "imageType": "pbf",
        "url": "http://localhost:8891/services/oregon"
      },
      {
        "imageType": "pbf",
        "url": "http://localhost:8891/services/washington"
      },
      {
        "imageType": "pbf",
        "url": "http://localhost:8891/services/british-columbia"
      }
    ]
    
    opened by kylebarron 6
  • Prebuilt executables with releases

    Prebuilt executables with releases

    Hello! This looks like a great project.

    I've seen many Go-based projects that have prebuilt executables with releases, that I think are autogenerated with Travis CI. I know you have a docker image, but it would be awesome to be able to easily download a built executable to a new cloud server without needing to install docker or Go.

    Is this something you'd consider?

    opened by kylebarron 6
  • Docker image link seems to be broken / unpublished

    Docker image link seems to be broken / unpublished

    Hi and thanks for this great project :)

    There are 2 things that didn't work for me while following the README:

    1. The local installation output was blank (go get github.com/consbio/mbtileserver) and while trying to run mbtileserver I receive a command not found message
    2. The docker image seems to not be working at all. While trying to pull the docker image I receive this:

    docker pull consbio/mbtileserver:latest Error response from daemon: pull access denied for consbio/mbtileserver, repository does not exist or may require 'docker login'

    Any help would be very appreciated.

    opened by carlos-mg89 6
  • Serve Mapbox-GL style files

    Serve Mapbox-GL style files

    is it possible to serve other files; i.e. like a standard http server? In particular I am trying to use mapbox-gl.js which uses a .json file to store the style and also the mbtiles source location. How can I serve the .json file from http://localhost? Thanks.

    opened by jimbok8 6
  • Bump decode-uri-component from 0.2.0 to 0.2.2 in /handlers/templates/static

    Bump decode-uri-component from 0.2.0 to 0.2.2 in /handlers/templates/static

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies javascript 
    opened by dependabot[bot] 1
  • Missing tiles returned as 256x256 transparent tiles

    Missing tiles returned as 256x256 transparent tiles

    Version 0.8.2:

    Currently missing (raster) tiles are always returned as 256x256 transparent tiles, even if the tile size is different, e.g. 512x512. This causes problems with some mapping software, e.g. maplibre-gl 2.3.0 terrain layers.

    If a tile does not exist, the tile server should return 404 not found (or possibly 204 no content, but this might also cause problems). At least there should be a switch to enable this behavior.

    opened by cns-solutions-admin 7
  • DOC: Add note that user needs to increase max open files limit if using several tilesets

    DOC: Add note that user needs to increase max open files limit if using several tilesets

    Observed on MacOS 10.15 with 25 tilesets, it is necessary to raise the max open files limit > 256 (default) or server panics at startup. This may be true for other environments as well. This appears to be due to the switch to crawshaw.io/sqlite from mattn/go-sqlite3, which did not have that issue.

    opened by brendan-ward 0
  • Build Error with GCC11

    Build Error with GCC11

    I cannot build this due to warnings with SQLite building.

    Looks like this may be fixed though and wonder if dependencies could be updated and a new version published?

    opened by leearmstrong 2
  • Consider adding a service reload API endpoint

    Consider adding a service reload API endpoint

    As mentioned in #128

    We may want to consider adding a reload API endpoint to trigger reload of a specific service or set of services, rather than restarting the entire server process. We'd probably need to set a mutex (so multiple calls to /reload in separate threads don't collide), then uses something similar to what we're doing in the filesystem watcher to rescan the registered directories and re-add those that exist, or take a service ID and reload just that one.

    We need to figure out how to handle auth for this; some options:

    • shared secret (your token); which is nice and lightweight but also risky, it could get logged as plaintext anywhere in between caller and mbtileserver and potentially used to do a DOS attack
    • HTTP Basic Auth based on credentials provided at server startup
    • something else?
    opened by brendan-ward 0
Releases(v0.9.0)
  • v0.9.0(Oct 20, 2022)

    Breaking changes

    • now requires Go 1.17+.

    General changes

    • upgraded Docker containers to Go 1.19
    • upgraded Go version used for release to Go 1.19

    Command-line interface

    • added support for specifying host IP address to listen on using the --host option (#138).
    • switched basemaps to Stamen map tiles (#148)
    • added auto-detection of tile size and return blank tile of same size (if available) for image tilesets when tile is not found (#155).
    Source code(tar.gz)
    Source code(zip)
    mbtileserver_v0.9.0_linux_386.zip(9.62 MB)
    mbtileserver_v0.9.0_linux_amd64.zip(9.78 MB)
    mbtileserver_v0.9.0_linux_arm64.zip(9.24 MB)
  • v0.8.2(Feb 17, 2022)

  • v0.8.1(Dec 28, 2021)

  • v0.8.0(Dec 22, 2021)

    General changes

    • display attribution in preview maps if present in tileset metadata.
    • upgraded Docker containers to Go 1.17.
    • upgraded Go version used for release to Go 1.17.
    • switched to go:embed for embedding templates and static assets.
    • dropped internal mbtiles package in favor of github.com/brendan-ward/mbtiles-go, which wraps the SQlite-specific go package crawshaw.io/sqlite for better performance.

    Command-line interface

    • added support for watching filesystem for changes to tilesets using --enable-fs-watch option.

    Breaking changes

    • now requires Go 1.16+.
    • removes ArcGIS API layer info at the service root and layers endpoint (#116); this was not providing useful information for image tilesets.
    • removed handlers.Assets; static assets are intended only for use in template or static file handlers.
    • removed support for UTF Grids.

    Bug Fixes

    • fix handlers for ArcGIS API endpoints, resolving tile shift issue (#116).
    • obviated incorrect include of node_modules in compiled asset file; executable is now smaller and faster to build.
    Source code(tar.gz)
    Source code(zip)
    mbtileserver_v0.8.0_linux_386.zip(8.59 MB)
    mbtileserver_v0.8.0_linux_amd64.zip(9.04 MB)
    mbtileserver_v0.8.0_linux_arm64.zip(8.21 MB)
  • v0.7.0(May 14, 2021)

    See the CHANGELOG for more details.

    General changes

    • substantial changes to internal functionality and HTTP handlers, see details below
    • now requires Go 1.13+
    • upgraded Docker containers to Go 1.16
    • upgraded Go version used for release to Go 1.16
    • removed vendor directory; no longer needed for Go 1.13
    • switched from Travis-CI to Github actions for running tests

    Command-line interface

    • added support for automatically generating unique tileset IDs using --generate-ids option

    • added ability to toggle off non-tile endpoints:

      • --disable-preview: disables the map preview, enabled by default.
      • --disable-svc-list: disables the list of map services, enabled by default
      • --disable-tilejson: disables the TileJSON endpoint for each tile service
      • --tiles-only: shortcut that disables preview, service list, and TileJSON endpoints
    • added ability to have multiple tile paths using a comma-delimited list of paths passed to --dir option

    • moved static assets for map preview that were originally served on /static endpoint to /services/<tileset_id>/map/static so that this endpoint is disabled when preview is disabled via --disable-preview.

    Go API

    • added ServiceSetConfig for configuration options for ServiceSet instances
    • added ServiceSet.AddTileset(), ServiceSet.UpdateTileset(), ServiceSet.RemoveTileset(), and ServiceSet.HasTileset() functions. WARNING: these functions are not yet thread-safe.

    Breaking changes

    Command-line interface:

    • ArcGIS endpoints are now opt-in via --enable-arcgis option (disabled by default)
    • --path option has been renamed to --root-url for clarity (env var is now ROOT_URL)
    • --enable-reload has been renamed to --enable-reload-signal

    Handlers API

    • ServiceSet.Handler parameters have been replaced with ServiceSetConfig passed to handlers.New() instead.
    • removed handlers.NewFromBaseDir(), replaced with handlers.New() and calling ServiceSet.AddTileset() for each Tileset to register.
    • removed ServiceSet.AddDBOnPath(); this is replaced by calling ServiceSet.AddTileset() for each Tileset to register.

    Bug fixes

    • Fixed WebP parsing, now uses simplified check for a RIFF header (WebP is only likely RIFF format to be stored in tiles). #98, #110
    Source code(tar.gz)
    Source code(zip)
    mbtileserver_v0.7.0_linux_386.zip(13.79 MB)
    mbtileserver_v0.7.0_linux_amd64.zip(14.38 MB)
  • v0.6.1(Apr 2, 2020)

  • v0.6.0(Mar 26, 2020)

    Changes:

    • fixed bug in map preview when bounds are not defined for a tileset (#84)
    • updated Leaflet to 1.6.0 and Mapbox GL to 0.32.0 (larger upgrades contingent on #65)
    • fixed issues with --tls option (#89)
    • added example proxy configuration for Caddy and NGINX (#91)
    • fixed issues with map preview page using HTTP basemaps (#90)
    • resolved template loading issues (#85)

    Breaking Changes: in handlers.go:

    • Removed TemplatesFromAssets as it was not used internally, and unlikely used externally
    • Removed secretKey from NewFromBaseDir parameters; this is replaced by calling SetRequestAuthKey on a ServiceSet.
    Source code(tar.gz)
    Source code(zip)
    mbtileserver_v0.6.0_linux_386.zip(12.34 MB)
    mbtileserver_v0.6.0_linux_amd64.zip(12.81 MB)
Owner
Conservation Biology Institute
Conservation Biology Institute
go chart is a basic charting library in native golang.

go-chart Package chart is a very simple golang native charting library that supports timeseries and continuous line charts. Master should now be on th

Will Charczuk 3.6k Dec 30, 2022
A library for basic image processing in Go.

Imaging Package imaging provides basic image processing functions (resize, rotate, crop, brightness/contrast adjustments, etc.). All the image process

null 0 Nov 26, 2021
A library for basic image processing in Go.

Imaging Package imaging provides basic image processing functions (resize, rotate, crop, brightness/contrast adjustments, etc.). All the image process

null 0 Nov 26, 2021
Storage and image processing server written in Go

Mort An S3-compatible image processing server written in Go. Still in active development. Features HTTP server Resize, Rotate, SmartCrop Convert (JPEG

Marcin Kaciuba 478 Jan 7, 2023
An image resizing server written in Go

picfit picfit is a reusable Go server to manipulate images (resize, thumbnail, etc.). It will act as a proxy on your storage engine and will be served

Florent Messa 1.7k Dec 24, 2022
Fast and secure standalone server for resizing and converting remote images

imgproxy imgproxy is a fast and secure standalone server for resizing and converting remote images. The main principles of imgproxy are simplicity, sp

imgproxy 6.8k Jan 1, 2023
An image server toolkit in Go (Golang)

Image Server An image server toolkit in Go (Golang) Features HTTP server Resize (GIFT, nfnt resize, Graphicsmagick) Rotate Crop Convert (JPEG, GIF (an

Pierre Durand 2k Dec 22, 2022
Go MBtiles reader

MBTiles Reader for Go A simple Go-based mbtiles reader. Supports JPG, PNG, WebP, and vector tile tilesets created according to the mbtiles specificati

Brendan Ward 2 May 7, 2022
Basic-api-with-go - A basic api with golang

I am creating my first API with GO. Install go get -u github.com/Yefhem/basic-ap

Yefhem 1 Jan 3, 2022
Go-basic-graphql - Basic implementation of GraphQL using Go

Go-basic-graphql - Basic implementation of GraphQL using Go

Luis Felipe Ribeiro 0 Jan 29, 2022
πŸ”₯ Golang Rest Api with basic JWT Authentication and Basic Crud Operations.

?? Golang Rest Api with basic JWT Authentication and Basic Crud Operations.

Junaid Javed 19 Oct 4, 2022
Go-basic-skeleton - Simple and basic skeleton for go projects

Go Bootstrap (base/skeleton) Introduction This is a repository intended to serve

Kenrique Ortega 2 Mar 16, 2022
Yeqllo 23 Nov 1, 2022
A basic file server automatically generates self certificates and serves the given folder.

A basic file server automatically generates self certificates and serves the given folder.

Ahmet Γ–ZER 4 Jul 20, 2022
A basic debugging server used when testing deployments

debug-server A basic debugging server used when testing deployments Development Start Server make Build This builds a Docker image with the commit has

Robin Joseph 0 Nov 1, 2021
A basic example of a go web server with a react frontend

GO-React starter This is a basic example of a go web server with a react frontend. It uses the go fiber framework Getting started Running locally Clon

Zidian Lyu 0 Nov 16, 2021
A very simple Golang server handling basic GET and POST requests

GOLANG SERVER INTRO As a true Blockchain enthusiast, I had to learn Solidity and Golang to participate to several projects. This repository consists o

null 0 Nov 17, 2021
A basic server built using golang.

Go Server A genral purpose server built using golang Go Server is a genral purpose server meant to be simple to use and begginner friendly. Currently

null 0 Dec 19, 2021
Basic and Digest HTTP Authentication for golang http

HTTP Authentication implementation in Go This is an implementation of HTTP Basic and HTTP Digest authentication in Go language. It is designed as a si

Lev Shamardin 529 Dec 22, 2022
A really basic thread-safe progress bar for Golang applications

progressbar A very simple thread-safe progress bar which should work on every OS without problems. I needed a progressbar for croc and everything I tr

Zack 3k Jan 2, 2023