Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/publish-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Publish GitHub Pages

# Publishes the demo site to GitHub Pages on every push to main and on each
# published release (and on manual dispatch). The site is assembled from the
# canonical sources at build time, so nothing has to be hand-copied into
# docs/ anymore:
# - docs/index.html -> / (the demo page)
# - styles/golfTilesStyle.json -> /styles/ (pmtiles URL rewritten to the
# Pages origin: golftiles.org
# sends no CORS headers)
# - docs/samples/*.pmtiles -> /samples/ (example tilesets)
# - docs/fonts/ -> /fonts/ (self-hosted glyph ranges)
#
# Requires the repo's Pages source to be set to "GitHub Actions"
# (one-time: gh api -X PUT repos/HuggeK/golfTiles/pages -f build_type=workflow).

on:
push:
branches: [main]
release:
types: [published]
workflow_dispatch: # allow manual runs from the Actions tab

# Never cancel a deployment in progress; queue instead.
concurrency:
group: pages
cancel-in-progress: false

jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
pages: write # required to deploy to Pages
id-token: write # required by deploy-pages for OIDC verification
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure Pages
id: pages
uses: actions/configure-pages@v5

- name: Assemble site
env:
BASE_URL: ${{ steps.pages.outputs.base_url }}
run: |
mkdir -p _site/styles _site/samples
cp docs/index.html _site/index.html
cp docs/samples/*.pmtiles _site/samples/
cp -r docs/fonts _site/fonts
# The canonical style points its pmtiles source at golftiles.org,
# which serves no CORS headers; the Pages copy must fetch tiles from
# its own origin. The same applies to glyphs: the canonical style
# declares none, so point it at the ranges copied above, otherwise
# docs/fonts/ ships for nothing and labels fall back to locally
# rendered glyphs. Both rewrites keep styles/golfTilesStyle.json
# itself untouched. jq doubles as a JSON validity gate.
jq --arg url "pmtiles://${BASE_URL}/samples/golfTiles_se_dk_fi.pmtiles" \
--arg glyphs "${BASE_URL}/fonts/{fontstack}/{range}.pbf" \
'.sources.golfTiles_source.url = $url | .glyphs = $glyphs' \
styles/golfTilesStyle.json > _site/styles/golfTilesStyle.json

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: _site

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
/.vscode
*:Zone.Identifier
!/docs/samples/*.pmtiles
!/tests/fixtures/*.pbf
!/tests/fixtures/*.pbf
!/docs/fonts/**/*.pbf
/_site
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ golfTiles/
│ └── process.lua # Process file which decides what should be included in the tiles in what layers and what vector attributes should be written to the features(Schema)
├── data/ # Folder to place your .pbf extracts to generate tiles on.
│ └── processed/ # Temporary folder used by the run_all.sh script for osmium-tool.
├── docs/ # Documentation.
├── docs/ # Documentation + sources for the GitHub Pages demo site.
│ ├── fonts/ # Self-hosted glyph .pbf ranges used by the style's glyphs property.
│ ├── samples/ # folder for samples to be downloaded by interested parties and used by the demo.
│ ├── styles/ # mirrors the styles/ folder, to be use on the github pages due to CORS
│ ├── CONTRIBUTING.md # Contributing information.
│ ├── diary.md # Some development diary documenting the early process.
│ └── index.html # The page for github pages.
│ └── index.html # The demo page for github pages.
├── openfreemap-styles/ # Git Submodule of openfreemap-styles using the OpenMapTiles schema.
├── store/ # Folder to be used as swapspace for tilemaker. TBD.
├── styles/ # Contains the maplibre GL Styles golfTilesStyle.json,
Expand All @@ -118,6 +118,16 @@ golfTiles/
└── run_all.sh # Main script to get generate .pmtiles.
```

## Publishing the demo site
The GitHub Pages demo (https://huggek.github.io/golfTiles/) is published by the
[`publish-pages.yml`](.github/workflows/publish-pages.yml) workflow, which runs on every push to
main and on every published release (or manually from the Actions tab). It assembles the site from the canonical sources — the
demo page (`docs/index.html`), the style (`styles/golfTilesStyle.json`, with its pmtiles source URL
rewritten to the Pages origin since golftiles.org serves no CORS headers), the example tilesets
(`docs/samples/`) and the self-hosted font glyphs (`docs/fonts/`) — so no copies need to be kept in
sync by hand. Longer term, golftiles.org is meant to be the bucket endpoint serving the tiles and
the style, with the GitHub Pages site acting as the demo page.

## Future technical development to solve the limitation using tileMaker
In the future one could maybe use a "dynamic" tile generator server such as:
- osm2psql
Expand Down
92 changes: 92 additions & 0 deletions docs/fonts/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
Copyright 2020 The Open Sans Project Authors (https://github.com/googlefonts/opensans)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://scripts.sil.org/OFL

-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to
provide a free and open framework in which fonts may be shared and
improved in partnership with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software
components as distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to,
deleting, or substituting -- in part or in whole -- any of the
components of the Original Version, by changing formats or by porting
the Font Software to a new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed,
modify, redistribute, and sell modified and unmodified copies of the
Font Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created using
the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added docs/fonts/Open Sans Regular/0-255.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/1024-1279.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/1280-1535.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/256-511.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/42752-43007.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/43776-44031.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/512-767.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/64256-64511.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/65280-65535.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/768-1023.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/7680-7935.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/7936-8191.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/8192-8447.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/8448-8703.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/8704-8959.pbf
Binary file not shown.
Binary file added docs/fonts/Open Sans Regular/9472-9727.pbf
Binary file not shown.
50 changes: 50 additions & 0 deletions docs/fonts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Self-hosted font glyphs

These are prebuilt SDF glyph ranges (`{fontstack}/{range}.pbf`) consumed by the MapLibre GL style
via its top-level `glyphs` property:

```
https://huggek.github.io/golfTiles/fonts/{fontstack}/{range}.pbf
```

GitHub Pages serves everything with `Access-Control-Allow-Origin: *`, so the same URL also works
when the style is served from golftiles.org or embedded in third-party apps.

## Source and license

- Generated from the current upstream **Open Sans**, the variable font
[`ofl/opensans/OpenSans[wdth,wght].ttf`](https://github.com/google/fonts/tree/main/ofl/opensans)
in `google/fonts`.
- Licensed under the [SIL Open Font License 1.1](https://openfontlicense.org/), © 2020 The Open
Sans Project Authors. A verbatim copy ships beside the glyphs as [`OFL.txt`](OFL.txt) and is
published at `/fonts/OFL.txt`; the OFL requires the licence and copyright notice to travel with
any redistribution, and these `.pbf` ranges are derived from the font.
- Open Sans was **relicensed from Apache 2.0 to OFL 1.1 in March 2021**, when it became a variable
font. Older prebuilt ranges (for example those from `fonts.openmaptiles.org`) are built from the
pre-2021 static TTFs and are still Apache 2.0. Do not mix the two without also changing `OFL.txt`.

## Why only 16 files, not 256

MapLibre requests glyphs one 256-codepoint block at a time, so a complete fontstack is 256 files
covering the whole Basic Multilingual Plane. For Open Sans only **16 of those blocks contain any
glyphs** — the other 240 are ~32-byte empty stubs for scripts the font does not cover, so they are
not committed.

A range that is absent 404s instead of returning an empty file. MapLibre treats both the same way:
it warns once and falls back to rendering that codepoint locally. Since the omitted blocks have no
glyphs to begin with, nothing renders differently — the only change is a console warning instead of
a silent empty response, and only for text outside Open Sans's coverage.

## Regenerating

The ranges were produced with MapLibre's own [font-maker](https://github.com/maplibre/font-maker)
WASM build (`sdfglyph.wasm`), which is what <https://maplibre.org/font-maker> runs. Drop the
variable TTF into that page, name the stack exactly `Open Sans Regular` so it matches `text-font`
in `styles/golfTilesStyle.json`, download the ZIP, and keep only the non-empty ranges. FreeType
uses the variable font's default instance (`wght` 400, `wdth` 100), which is Regular.

## Adding another fontstack

Put the new stack's ranges in a sibling directory named exactly like the fontstack (spaces
included), e.g. `Open Sans Bold/0-255.pbf`, and reference it from the style's `text-font`. The
`publish-pages.yml` workflow copies the whole `docs/fonts/` directory into the published site.
40 changes: 31 additions & 9 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>golfTiles.org</title>
<title>golfTiles</title>
<meta name="description" content="Free and open-source golf centric vector tiles with custom style for websites and apps, using OpenStreetMap data">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Maplibre stylesheet. Keep the major version pinned: an unpinned
Expand All @@ -14,19 +14,19 @@
<script src="https://unpkg.com/pmtiles@3.2.0/dist/pmtiles.js"></script>
</head>
<body>
<h1>golfTiles.org</h1>
<h1>golfTiles</h1>

<p>Link to github repo: <a href="https://github.com/HuggeK/golfTiles">https://github.com/HuggeK/golfTiles</a></p>

<h3>Example PMtiles: </h3>
<ul>
<li><a href="https://huggek.github.io/golfTiles/samples/golfTiles_se_dk_fi.pmtiles" download>samples/golfTiles_se_dk_fi.pmtiles</a></li>
<li><a href="https://huggek.github.io/golfTiles/samples/golfTiles_sweden.pmtiles" download>samples/golfTiles_sweden.pmtiles</a></li>
<li><a href="samples/golfTiles_se_dk_fi.pmtiles" download>samples/golfTiles_se_dk_fi.pmtiles</a></li>
<li><a href="samples/golfTiles_sweden.pmtiles" download>samples/golfTiles_sweden.pmtiles</a></li>
</ul>

<p>If you want to inspect the tiles themselves I can recommend downloading the samples and use <a href="https://pmtiles.io/">pmtiles.io</a>.</p>

<p>Domain: <a href="https://golftiles.org">golftiles.org</a></p>
<p>This demo is hosted on GitHub Pages: <a href="https://huggek.github.io/golfTiles/">https://huggek.github.io/golfTiles/</a>. Main domain: <a href="https://golftiles.org">golftiles.org</a></p>

<h2>Initial Demo using Maplibre GL JS over Sweden, finland and Denmark: </h2>
<p>Extract from 260601. Initial position is over course: <a href="https://www.openstreetmap.org/way/101624685">Way: Emmaboda Golfklubb (101624685)</a> </p>
Expand All @@ -41,7 +41,9 @@ <h2>Initial Demo using Maplibre GL JS over Sweden, finland and Denmark: </h2>
const protocol = new pmtiles.Protocol();
maplibregl.addProtocol('pmtiles', protocol.tile);

const PMTILES_URL = 'https://huggek.github.io/golfTiles/samples/golfTiles_se_dk_fi.pmtiles'; // will this add source two times? both in style and in new?
// Absolute URL matching the one the publishing workflow writes into the
// style's source, so the map reuses this pre-registered instance.
const PMTILES_URL = new URL('samples/golfTiles_se_dk_fi.pmtiles', location.href).href;

const p = new pmtiles.PMTiles(PMTILES_URL);

Expand All @@ -52,12 +54,32 @@ <h2>Initial Demo using Maplibre GL JS over Sweden, finland and Denmark: </h2>
p.getHeader().then(h => {
const map = new maplibregl.Map({
container: 'map',
zoom: h.maxZoom - 2, // golfTiles is rendered at max zoom of 14.
zoom: h.maxZoom - 1, // golfTiles is rendered at max zoom of 14.
center: [15.59411, 56.52839], //Centers on Emmaboda GK.
style: 'https://huggek.github.io/golfTiles/styles/golfTilesStyle.json'
pitch: 70,
style: 'styles/golfTilesStyle.json',
maxPitch: 85
});
map.addControl(
new maplibregl.NavigationControl({
visualizePitch: true,
showZoom: true,
showCompass: true
})
);

map.addControl(
new maplibregl.TerrainControl({
source: 'terrainSource',
exaggeration: 1
})
);
});
</script>

<p><small>Map labels are rendered with <a href="https://fonts.google.com/specimen/Open+Sans">Open Sans</a>,
© 2020 The Open Sans Project Authors, licensed under the
<a href="fonts/OFL.txt">SIL Open Font License 1.1</a>.</small></p>

</body>
</html>
</html>
Loading
Loading