https://github.com/markuman/sms Skip to content Navigation Menu Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + GitHub Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions By size + Enterprise + Teams + Startups By industry + Healthcare + Financial services + Manufacturing By use case + CI/CD & Automation + DevOps + DevSecOps * Resources Topics + AI + DevOps + Security + Software Development Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} markuman / sms Public * Notifications You must be signed in to change notification settings * Fork 4 * Star 130 simple mbtiles server License MIT license 130 stars 4 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 1 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights markuman/sms This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. latest BranchesTags Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 10 Commits simple_mbtiles_server simple_mbtiles_server test test .gitignore .gitignore Dockerfile Dockerfile LICENSE LICENSE MANIFEST.in MANIFEST.in README.md README.md example.html example.html map.sh map.sh requirements.txt requirements.txt setup.py setup.py View all files Repository files navigation * README * MIT license [?] OSM - self host the entire planet in ~30 minutes simple mbtiles server TL;DR mkdir osm wget -O osm/planet.mbtiles https://hidrive.ionos.com/api/sharelink/download?id=SYEgScrRe podman run -ti --rm -p 9000:9000 --name sms -v $(pwd)/osm/:/data/ registry.gitlab.com/markuman/sms:latest firefox http://localhost:9000 requirements: * podman (or docker) * 90 GB storage is required (1 core and 512MB memory are sufficient ) notes: * "~30 minutes" depends on your bandwidth ...and the hidrive performance of ionos. support * My Project: https://github.com/markuman/sms * For the large planet.mbtiles generation and hosting, donations are welcome + paypal.me/MarkusBergholz + bc1qz33cf70vq82gxf8kps06j7lv7m2903hsnjak6k credits * https://github.com/onthegomap/planetiler is used to generate the planet.mbtiles file * https://github.com/uktrade/mbtiles-s3-server is the origin code-base of my sms project nextcloud GpxPod 1. Deploy the container/service behind a webproxy (caddy, nginx, traefik,...you name it.) to get a valid SSL version. 2. Goto GpxPod Settings -> Tile Servers + Type: Vector + Server address: https:///v1/ styles/osm-bright-gl-style@1.0.0/style.json?fonts= fonts-gl@1.0.0&tiles=mytiles@1.0.0 HELP WANTED * Improve Style for Nextcloud GxpPod * Add contour lines planet.mbtiles My provided planet.mbtiles is generated by using https://github.com/ onthegomap/planetiler Example usage 1. Create or obtain an mbtiles file, for example from https:// openmaptiles.org/. 2. Start this server, configured with the location of this object and credentials for this user - it's configured using environment variables. You can assign the tiles file any version you like, in this case, 1.0.0. #!/bin/bash PORT=8080 \ MBTILES__1__URL=/home/m/osm/planet.mbtiles \ MBTILES__1__MIN_ZOOM=0 \ MBTILES__1__MAX_ZOOM=14 \ MBTILES__1__IDENTIFIER=mytiles \ MBTILES__1__VERSION=1.0.0 \ HTTP_ACCESS_CONTROL_ALLOW_ORIGIN="*" \ python3 -m simple_mbtiles_server 3. On your user-facing site, include HTML that loads these tiles from this server, for example to load maps from a server started as above running locally serving OpenMapTiles Example map
This HTML is included in this repository in example.html. A simple server can be started to view it by python -m http.server 8081 --bind 127.0.0.1 and going to http://localhost:8081/example.html Core API GET /v1/tiles/{identifier}@{version}/{z}/{x}/{y}.mvt Fetch a tile in Mapbox Vector Tile (MVT) format * identifier An aribtrary identifier for a tileset configued via environment variables when starting the server, for example MBTILES__1__IDENTIFIER (see Example usage). * version A version for a tileset configued via environment variables, for example MBTILES__1__VERSION (see Example usage). The version is part of the API to encourage releasing a new version of a tileset rather than replacing an existing one. An arbitrary version of the tileset identified by the identifier. * z, x, y The xyz coordinates of a tile in this tileset For the curious, advanced, or developers of this server itself Hosting your own vector map tiles to show them in a browser requires quite a few components: 1. JavaScript and CSS A Javascript and CSS library, such as MapLibre GL, and your own code to run this library, pointing it to a style file 2. Style file A JSON file that defines how the library should visually style the map data, and where it should find the map tiles, glyphs (fonts), and the sprite. This server transforms the built-in Style files on the fly to be able to refer to any map data. 3. Glyphs (fonts) Different fonts can be used for different labels and zoom levels, as defined in the Style file. The fonts must Signed Distance Field (SDF) fonts wrapped in a particular Protocol Buffer format. The Style file can refer to "stacks" of fonts; but unlike CSS, the server combines the fonts on the fly in an API where the resulting "font" has at most one glyph from each source font. 4. Sprite A sprite is actually 4 URLs: a JSON index file and a single PNG file, and a "@2x" JSON index file and PNG files for higher pixel ratio devices (e.g. Retina). The JSON files contains the offsets and sizes of images within corresponding PNG file. The style file refers the common "base" of these. For example, if the style file has "sprite":"https://my.test/sprite" then the 4 files must be at https://my.test/sprite.json, https://my.test/sprite.png, https:// my.test/sprite@2x.json and https://my.test/sprite@2x.png. 5. Vector map tiles A set of often millions of tiles each covering a different location and different zoom level. These can be distributed as a single mbtiles file, but this is not the format that the Javascript library accepts. This on-the-fly conversion from the mbtiles file to tiles is the main feature of this server. The mbtiles file is a SQLite file, containing gzipped Mapbox Vector Tile tiles. This server leaves the un-gzipping to the browser, by sending tiles with a content-encoding: gzip header, which results in browser un-gzipping the tile data before it hits the Javascript. Licenses The code of the server itself is released under the MIT license. However, several components included in mbtiles_s3_server/vendor/ are released under different licenses. About simple mbtiles server Resources Readme License MIT license Activity Stars 130 stars Watchers 4 watching Forks 4 forks Report repository Releases No releases published Packages 0 No packages published Languages * Python 92.6% * HTML 3.0% * Shell 2.9% * Dockerfile 1.5% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.