Skip to content

Commit

Permalink
Merge pull request #2235 from pedro-andrade-inpe/master
Browse files Browse the repository at this point in the history
Pedro's updates to terrame 2.0-RC8 - part 4
  • Loading branch information
pedro-andrade-inpe authored Aug 13, 2018
2 parents 47f132a + 34910b8 commit 47faf09
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions packages/gis/lua/Layer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1429,18 +1429,24 @@ 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

data.project = Project{
file = data.project
}
elseif pType ~= "Project" then
mandatoryTableArgument(data, "project", "Project")
end

if data.file and type(data.file) == "string" then
Expand Down
2 changes: 1 addition & 1 deletion packages/gis/lua/TerraLib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions packages/gis/tests/functional/alternative/Layer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 47faf09

Please sign in to comment.