unvt / charites

It is an application to style vector tiles easily
https://unvt.github.io/charites/
MIT License
54 stars 13 forks source link

Serve with static files in the local directory #89

Closed yuiseki closed 2 years ago

yuiseki commented 2 years ago

Description

Add capability to serve additional static files in the local directory for charites.

That means charites gets capability to serve tilesets itself if tiles has split as /{z}/{x}/{y}/*.pbf style in the local directory.

This pull request possibly related to issue #73

Why

Currently charites has no capability to serve any tilesets itself. So charites require another server that serving some tilesets.

This can be a problem if you have a poor connection or are cut off from the Internet. I would like to be able to edit map styles without having to set up another server.

In addition, this can turn charites into a complete map server on its own.

Example

This pull request add capability to serve vector tile tilesets in the local directory.

  1. Create vector tile to ./docs/zxy/{z}/{x}/{y}/*.pbf

  2. Write or generate TileJSON to docs/tiles.json like below

  "tiles": [
    "http://localhost:8080/zxy/{z}/{x}/{y}.pbf"
  ]
  1. Write style.yml like below
sources:
  openmaptiles:
    type: vector
    url: ./tiles.json
  1. Run charites serve style.yml --local-dir docs

Open http://localhost:8080/ without connection to Internet. That will works.

Type of Pull Request

Verify the followings

Refer to CONTRIBUTING.MD for more details.

JinIgarashi commented 2 years ago

@yuiseki Thank you for your pull request.

@hfu @naogify What do you think this feature? I assume it is out of scopes of charites to have a feature distributing tiles. There are serveral useful servers to distribute from mbtiles. For instance, mbtiles-server, mbtileserver, tileserver-gl can be used together with charites. However, it is still necessary to fix https://github.com/unvt/charites/issues/73 issue to be able to change default port of charites in order to use other tile server at the same time. Maybe we can include #73 in v1.0.0.

Or, another option can be to utilise naru. If charites will be introduced in naru, it can provide all in one environment to create tiles with style.json.

hfu commented 2 years ago

Many thanks for the pull request and the mention. I have a few comments:

  1. For mbtiles-server, mbtileserver, and tileserver-gl are vector tiles server from MBTiles files, there is some difference with this pull request.
  2. naru is a capacity-building material rather than a software tool.
  3. On the other hand, I love the concept of DOTADIW, or "Do One Thing And Do It Well."

Oh, by the way I love using budo when hosting static files.

naogify commented 2 years ago

@yuiseki Thanks for the PR request!

@JinIgarashi @hfu I also think that serving tiles is outside the scope of charites role.

I think the use case listed below could be covered by a tool that hosts tiles locally, such as tileserver-gl or budo.

if you have a poor connection or are cut off from the Internet.

But for using those tools, especially tileserver-gl, I agree that we need to fix #73.

yuiseki commented 2 years ago

Hi everyone.

Thanks to careful comments for my pull request! It was a pleasure to hear everyone's opinion.

Honestly, I also think maybe serving tiles is out of scope of charites. And I also agree the Do one thing concept of UNIX philosophy.

I was wondering if perhaps this change might be needed other one, But after listening to everyone's opinions, I've reconsidered that this change is not necessary for charites.

So, now I decide to close this pull request.

I'd like to find another way to resolve #73.

Thank you everyone so much. See you in another pull request!