Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify API by allowing any Path-like params #57

Merged
merged 2 commits into from
Jun 15, 2023

Conversation

nyurik
Copy link
Contributor

@nyurik nyurik commented Jun 13, 2023

This is the same approach as used by some stdlib functions

@nyurik nyurik changed the title Simplify API by allowing any Path-like obj Simplify API by allowing any Path-like params Jun 13, 2023
@flother
Copy link
Owner

flother commented Jun 15, 2023

Is this similar to #59 in that this is useful when using Spreet as a library?

@nyurik
Copy link
Contributor Author

nyurik commented Jun 15, 2023

Exactly, it allows multiple call styles. If you look at the core lib, it has the same pattern for path params

@nyurik
Copy link
Contributor Author

nyurik commented Jun 15, 2023

Btw, unrelated, but please consider renaming primary branch to main. Github has a lot of support for that, it's very simple. Thx for an awesome lib!

@flother flother merged commit 768d9f7 into flother:master Jun 15, 2023
@nyurik nyurik deleted the pathref branch June 15, 2023 21:10
nyurik added a commit to maplibre/martin that referenced this pull request Jun 16, 2023
Dynamically create image sprites for MapLibre rendering, given a
directory with images.

### TODO
* [x] Work with @flother to merge these PRs
  * [x] flother/spreet#59  (must have)
  * [x] flother/spreet#57
  * [x] flother/spreet#56
* [ ] flother/spreet#62 (not required but nice
to have, can upgrade later without any code changes)
* [x] Add docs to the book
* [x] Add CLI param, e.g. `--sprite <dir_path>`
* [x] Don't output `.sprites` in auto-genned config when not in use

### API
Per [MapLibre sprites
API](https://maplibre.org/maplibre-style-spec/sprite/), we need to
support the following:
* `/sprite/<sprite_id>.json` metadata about the sprite file - all coming
from a single directory
* `/sprite/<sprite_id>.png` all images combined into a single PNG
* `/sprite/<sprite_id>@2x.json` same but for high DPI devices
* `/sprite/<sprite_id>@2x.png`

Multiple sprite_id values can be combined into one sprite with the same
pattern as for tile joining:
`/sprite/<sprite_id1>,<sprite_id2>,...,<sprite_idN>[.json|.png|@2x.json|@2x.png]`.
No ID renaming is done, so identical names will override one another.

### Configuration
[Config file](https://maplibre.org/martin/config-file.html) and possibly
CLI should have a simple option to serve sprites. The configuration may
look similar to how mbtiles and pmtiles are configured:

```yaml
# Publish sprite images
sprites:
  paths:
    # scan this whole dir, matching all image files, and publishing it as "my_images" sprite source
    - /path/to/my_images
  sources:
    # named source matching source name to a directory
    my_sprites: /path/to/some_dir
```

Implement #705
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants