diff --git a/packages/gis/lua/Layer.lua b/packages/gis/lua/Layer.lua index d60407a5..1e624b0d 100644 --- a/packages/gis/lua/Layer.lua +++ b/packages/gis/lua/Layer.lua @@ -1429,11 +1429,15 @@ metaTableLayer_ = { function Layer(data) verifyNamedTable(data) mandatoryTableArgument(data, "name", "string") - if type(data.project) == "string" then + + local pType = type(data.project) + + if pType == "string" then data.project = File(data.project) + pType = "File" end - if type(data.project) == "File" then + if pType == "File" then if not data.project:exists() then customError("Project file '"..data.project.."' does not exist.") end @@ -1441,6 +1445,8 @@ function Layer(data) data.project = Project{ file = data.project } + elseif pType ~= "Project" then + mandatoryTableArgument(data, "project", "Project") end if data.file and type(data.file) == "string" then diff --git a/packages/gis/lua/TerraLib.lua b/packages/gis/lua/TerraLib.lua index 3b3223cc..ff496b20 100644 --- a/packages/gis/lua/TerraLib.lua +++ b/packages/gis/lua/TerraLib.lua @@ -592,7 +592,7 @@ local function createCellSpaceLayer(inputLayer, name, dSetName, resolution, conn inputLayer:getExtent(), inputLayer:getSRID(), cLType) end - if errorMsg ~= "" then + if errorMsg and errorMsg ~= "" then if type == "POSTGIS" then customError(getPgErrorMessage({layer = inputLayer:getTitle()}, errorMsg)) end diff --git a/packages/gis/tests/functional/alternative/Layer.lua b/packages/gis/tests/functional/alternative/Layer.lua index c063b26c..b425efaf 100644 --- a/packages/gis/tests/functional/alternative/Layer.lua +++ b/packages/gis/tests/functional/alternative/Layer.lua @@ -38,6 +38,12 @@ return{ unitTest:assertError(projNotExists, "Project file '"..File("myproj.tview").."' does not exist.") + local noProj = function() + Layer{file = "myfile.shp", name = "name"} + end + + unitTest:assertError(noProj, mandatoryArgumentMsg("project")) + local projFile = File("proj_celllayer.tview") projFile:deleteIfExists()