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

API refactor #46

Open
akhenakh opened this issue Mar 16, 2023 · 4 comments
Open

API refactor #46

akhenakh opened this issue Mar 16, 2023 · 4 comments

Comments

@akhenakh
Copy link

Hi first thanks for this project.

I'm moved my project from mbtiles to a dedicated kv solution and finally to pmtiles which is way better, problem is the actual go-pmtiles is not directly usable as an API.

I had to copy some private part of your code, to create a different http handler https://github.com/akhenakh/kvtiles/blob/master/storage/pmtiles/pmtiles.go

Are you planning on making a more Goish API?

@bdon
Copy link
Member

bdon commented Mar 17, 2023

Hi, the current code isn't really meant to expose a programmatic API beyond the CLI. Copying those bits of low-level parts seems like a good enough solution for now.

Because I don't use the Go module myself yet I would appreciate some feedback on what the use cases are, for example which of the CLI functionality you would want to use in your Go program. The big one is #31 which isn't finished yet.

@akhenakh
Copy link
Author

You can see your public code over here:

https://pkg.go.dev/github.com/protomaps/go-pmtiles@v1.7.0/pmtiles

  • There is no way to parse a headerv3.
  • There is no way to read a tile without using all your server handler, this one is the bare minimum for this lib to be usable.

@bdon
Copy link
Member

bdon commented Mar 23, 2023

@akhenakh thanks - would adding utility functions for parsing headers help accomplish what you need for your project?

On the topic of reading tiles - I don't think there is one single answer for all use cases. The server right now barely handles local files and S3-like cloud storage with an LRU cache, however it needs to be adaptable to:

  • public HTTP endpoints
  • other caching strategies - if you are reading a large block of tiles, an LRU cache may not be efficient compared to pre-loading the entire directory section in memory

A program that scrapes (politely) or generates tiles and inserts them into a PMTiles archive is a good example of what I envision the Go API being used for. This is definitely on the roadmap but not an immediate priority right now so I'm open to an intermediate "good enough" refining of the API.

@bdon
Copy link
Member

bdon commented Sep 22, 2023

(Leaving this as a breadcrumb... https://go.dev/doc/modules/layout)

bdon added a commit that referenced this issue Jan 28, 2024
]

* Use revive with the default configuration.
bdon added a commit that referenced this issue Jan 28, 2024
#123)

* Make all variable and field names consistent with style guide. [#20, #46]

* Use revive with the default configuration.

* also do error string and code style cleanup (revive defaults)
bdon added a commit that referenced this issue Jan 29, 2024
…#46]

* Also correct ordering of function arguments to put errors last
bdon added a commit that referenced this issue Jan 29, 2024
#124)

* refactor names to only export intentional parts of functionality [#20, #46]

* Also correct ordering of function arguments to put errors last

* add go vet to CI, fix CLI syntax
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

No branches or pull requests

2 participants