mactrem / com-tiles

Streamable and read optimized file archive for hosting map tiles at global scale on a cloud object storage
MIT License
94 stars 12 forks source link

Support for multiple url caches, custom protocol name and using comt source as tilejson url #13

Closed Oreilles closed 1 year ago

Oreilles commented 1 year ago

The current Maplibre protocol implementation has some flaws that this PR tries to address.

  1. From my understanding, the current comtCache object is overriden each time a new root comt source url is accessed, meaning that having two maps instanciated from the same global maplibre object and showing two different comt files would have their tile caches overwriten each time the other map would request a tile.

  2. It's currently not possible to choose the name the protocol will be added with.

  3. A comt source must be added within the vector source tiles array property, and cannot be added with the url property.

  4. The tileFetchStrategy check for BATCHED or SINGLE was included inside the custom protocol function, which adds an avoidable overhead. The check is now moved in the provider constructor.

Previously:

MapLibreComtProvider.register(TileFetchStrategy.SINGLE)

Now:

const provider = new MapLibreComtProvider(TileFetchStrategy.SINGLE)
provider.register()
// or
maplibregl.addProtocol('com-tiles', provider.protocol)

Previously possible:

"test-source": {
    "type": "vector",
    "tiles": [
      "comt://http://0.0.0.0:9000/comtiles/test.comt/{z}/{x}/{y}"
    ]
}

Now also possible

"test-source": {
    "type": "vector",
    "url":  "comt://http://0.0.0.0:9000/comtiles/test.comt"
}

I would happily discuss the propositions made and the implementation details.

Oreilles commented 1 year ago

Thank for the review, the requested changes are done 👍