Permalink
Browse files

config: set datadir to lookuplocator

  • Loading branch information...
olt committed Aug 3, 2017
1 parent 756aa9a commit f916062cb8de150de1d086353e3738133729f8fa
Showing with 11 additions and 0 deletions.
  1. +7 −0 config/config.go
  2. +4 −0 config/config_test.go
View
@@ -103,6 +103,13 @@ func (m *Magnacarto) Locator() Locator {
}
locator.AddShapeDir(dir)
}
for _, dir := range m.Datasources.DataDirs {
if !filepath.IsAbs(dir) {
dir = filepath.Join(m.BaseDir, dir)
}
locator.AddDataDir(dir)
}
fontDirs := append([]string{}, m.Mapnik.FontDirs...)
fontDirs = append(fontDirs, m.Datasources.FontDirs...)
for _, dir := range fontDirs {
View
@@ -79,6 +79,8 @@ func TestLookupLocator_RelPaths(t *testing.T) {
// l.Data looks only in DataDir
existing(l.Data("data.geojson"), filepath.Join(relPrefix, "data", "data.geojson"))
existing(l.Data("./../data/data.geojson"), filepath.Join(relPrefix, "data", "data.geojson"))
existing(l.Data("../shp/file.shp"), filepath.Join(relPrefix, "shp", "file.shp"))
missing(l.Data("file.shp"), "file.shp", "file.shp")
missing(l.Image("test2.png"), "test2.png", "test2.png")
@@ -157,6 +159,8 @@ func TestLookupLocator_AbsPaths(t *testing.T) {
// l.Data looks only in DataDir
existing(l.Data("data.geojson"), filepath.Join(d.dir, "data", "data.geojson"))
existing(l.Data("./../data/data.geojson"), filepath.Join(d.dir, "data", "data.geojson"))
existing(l.Data("../shp/file.shp"), filepath.Join(d.dir, "shp", "file.shp"))
missing(l.Data("file.shp"), filepath.Join("/tmp", "file.shp"), "file.shp")
// missing files return abs path based on outDir

0 comments on commit f916062

Please sign in to comment.