millstone icon indicating copy to clipboard operation
millstone copied to clipboard

localizing datasources/resources representing more than one layer

Open springmeyer opened this issue 14 years ago • 1 comments

Flagging this issue as requiring more thought.

Consider these various issues:

  • Zipfiles - we currently assume its a shapefile and look for the first .shp, but there could be multiple. And eventually we'll want to support other datasources being zipped - like geojson: https://github.com/mapbox/tilemill/issues/253
  • KML files - can embed more than one layer - currently millstone passes layer_by_index:0 to mapnik to just take the first
  • SQLite databases - would be nice to be able to introspect and find all spatial tables

With the exception of zipped resources, the generic answer to these is using gdal/ogr to introspect the data (and therefore wrapping gdal/ogr as a node c++ addon). But, currently the approach of millstone is to handle each case in a custom way - with the benefit of avoiding the extra dependency and offering advanced functionality.

springmeyer avatar Aug 18 '11 14:08 springmeyer

Addressing this will require adjusting our architecture document a bit. Currently the only "verb" in millstone is resolve -- you pass it an MML and it hands it back to you with all of the resources localized and prepped for compilation/rendering.

To handle the cases above, however, millstone (or some other API component) would need to offer datasource inspection/introspection on a per-datasource basis with some accompanying UI in TileMill, e.g.

  • User selects zipfile in TileMill, uri like file:///some/path/to/zipfile.zip is handed to millstone
  • Millstone tells TileMill available datasources in zipfile like [ 'foo.shp', 'bar.shp', 'baz.shp' ] (I wonder whether millstone should actually do inspection at all or whether this should be TileMill's job, e.g. treat zipfiles, sqlite dbs, etc. like folders in the library browser)
  • User further selects specific datasource from zip and the actual layer uri is set to file:///some/path/to/zipfile.zip#foo.shp or using some other convention
  • Millstone resolve is called, unpacking foo.shp on the basis of uri zipfile.zip#foo.shp into a dir and referencing it in the localized MML.

^ this is just one possible workflow for this user story but I think the the basic sketch shows what kind of complexity we're talking about here.

yhahn avatar Aug 22 '11 14:08 yhahn