Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
config: set datadir to lookuplocator
- Loading branch information
Showing
with
11 additions
and
0 deletions.
-
+7
−0
config/config.go
-
+4
−0
config/config_test.go
|
@@ -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 { |
|
|
|
@@ -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 |
|
|