mapbox/tilemill — Issue #1214: Data Sources combined with Layers violates DRY
Author: llimllib
Created: 2012-01-24 20:06:30+00:00
State: open

In the current map structure, each layer has a data source, defined by a postgres connection string, a URL, a filename, or a SQLite database.

(In the postgres tab of the add layer dialog, "datasource" is called "connection string", but for the purposes of this argument it will be called the "datasource".)

In every tilemill map project which connects to a OSM import that I've seen, there are many layers which connect to the same OSM database.

If you want to change some attribute of the datasource, you are therefore required to either open each layer and manually edit the connection string or manually edit the project's mml file. Both are error-prone processes, and it would be much better if Tilemill would handle them for the user.

Furthermore, I imagine that many people will have multiple projects with layerspointing to the same datasource, for which they must specify the same connection string over and over again, multiplying the pain of every database change and making each layer addition slightly harder than it needs to be. (Every time I create a layer, I copy and paste the same connection string from some other layer or my notes file... not a process I look forward to or should have to do more than once.)

I also have to copy and paste the extent of my map every time I create a new layer, or I will pay the cost for Tilemill to step through each object in my database to determine the maximum extent of the database. It's easy to forget and costly when I do.

So! Tilemill should separate the concept of "datasource" from the concept of "layer". The user should maintain one list of data sources, and then when he creates a new layer he just chooses the data source from a dropdown list.

This allows for the easy creation of multiple maps which reference the same data source, makes it easier to duplicate projects on the same machine, and easier to copy projects to new machines with different database setups. (Just have the same name for your datasource on each machine, and they can have wholly different connection strings)

(This already kinda-sorta exists with Tilemill's layer cache!)

I'd be willing to help implement this idea if you all like it, and am happy to clarify why I think it'd be useful if I haven't been clear enough in this book-length issue :)