Skip to content

Commit

Permalink
Close TerraME#2336 - Remove fix feature of the Layer:check(), ref. Te…
Browse files Browse the repository at this point in the history
  • Loading branch information
avancinirodrigo committed Mar 31, 2020
1 parent 42f532f commit 779efd1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 37 deletions.
11 changes: 3 additions & 8 deletions packages/gis/lua/Layer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1396,9 +1396,6 @@ Layer_ = {
--- Checks if data layer geometries are valid.
-- If some invalid geometry are found, a warning is show about the problem.
-- Return true if no problem is found.
-- @arg fix A boolean value which if true tries to fix the geometries problems found.
-- If not set, its value will be false.
-- If it is not possible fix the geometries a error will be show.
-- @arg progress A boolean value indicating whether progress will be shown while fixing the geometries.
-- @usage --DONTRUN
-- local layer = Layer{
Expand All @@ -1410,14 +1407,12 @@ Layer_ = {
-- if not layer:check() then
-- layer:check(true)
-- end
check = function(self, fix, progress)
optionalArgument(2, "boolean", fix)
if fix == nil then fix = false end
optionalArgument(3, "boolean", progress)
check = function(self, progress)
optionalArgument(2, "boolean", progress)
if progress == nil then progress = true end

TerraLib().setProgressVisible(progress)
local problems = TerraLib().checkLayerGeometries(self.project, self.name, fix)
local problems = TerraLib().checkLayerGeometries(self.project, self.name)

if #problems > 0 then
customWarning(formatCheckGeometriesMsg(problems))
Expand Down
10 changes: 1 addition & 9 deletions packages/gis/lua/TerraLib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3681,11 +3681,10 @@ TerraLib_ = {
-- If invalid geometries are found, it returns a list of the problems.
-- @arg project A project.
-- @arg layerName The name of the layer.
-- @arg fix A boolean value which if true tries to fix the geometries problems founded.
-- @usage --DONTRUN
-- local problems = TerraLib().checkLayerGeometries(self.project, self.name)
-- print(problems[1].error, problems[1].coord.x, problems[1].coord.y)
checkLayerGeometries = function(project, layerName, fix)
checkLayerGeometries = function(project, layerName)
local problems = {}
local fixErrorMsg = ""

Expand All @@ -3707,13 +3706,6 @@ TerraLib_ = {
coord = {x = problem.coordX, y = problem.coordY}})
end

if fix and (#problems > 0) then
viewerId = createProgressViewer("Fixing '"..layerName.."' geometries")
fixErrorMsg = binding.te.vp.MakeGeometryValid.makeValid(layer,
layer:getDataSetName(), geomError.objectIdSet)
finalizeProgressViewer(viewerId)
end

releaseProject(project)
end

Expand Down
8 changes: 1 addition & 7 deletions packages/gis/tests/functional/alternative/Layer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1350,17 +1350,11 @@ return{
}

local fixTypeError = function()
l1:check(1, false)
l1:check(1)
end

unitTest:assertError(fixTypeError, incompatibleTypeMsg(2, "boolean", 1))

local progressTypeError = function()
l1:check(true, "true")
end

unitTest:assertError(progressTypeError, incompatibleTypeMsg(3, "boolean", "true"))

l1:delete()
proj.file:delete()
end
Expand Down
5 changes: 2 additions & 3 deletions packages/gis/tests/functional/basic/Project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ return {
directory = packageInfo("gis").data.."test"
}

unitTest:assertEquals(getn(proj.layers), 27)
unitTest:assertEquals(getn(proj.layers), 28)
file:deleteIfExists()

local version = ""
Expand Down Expand Up @@ -312,8 +312,7 @@ return {
spfile:copy(currentDir())

local qgp = Project {
file = File("sampa_v3.qgs"),
clean = true
file = File("sampa_v3.qgs")
}

local l1 = Layer{
Expand Down
6 changes: 2 additions & 4 deletions packages/gis/tests/shapefile/basic/Layer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ return {
warnMsg = msg
end

unitTest:assert(not l1:check(true, false))
unitTest:assert(not l1:check(false))

if string.find(warnMsg, "5502300.9611873") then
unitTest:assertEquals(warnMsg, "The following problems were found in the geometries:\n" --SKIP
Expand Down Expand Up @@ -1264,7 +1264,7 @@ return {
warnMsg = msg
end

unitTest:assert(not l1:check(true, false))
unitTest:assert(not l1:check(false))

if string.find(warnMsg, "5502300.9611873") then
unitTest:assertEquals(warnMsg, "The following problems were found in the geometries:\n" --SKIP
Expand All @@ -1284,8 +1284,6 @@ return {

customWarning = customWarningBkp

unitTest:assert(l1:check(true, false))

l1:delete()
proj.file:delete()
end
Expand Down
7 changes: 1 addition & 6 deletions packages/gis/tests/shapefile/basic/TerraLib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2480,19 +2480,14 @@ return {

TerraLib().setProgressVisible(false)

local fix = true
local problems = TerraLib().checkLayerGeometries(proj, l1Name, fix)
local problems = TerraLib().checkLayerGeometries(proj, l1Name)

unitTest:assertEquals(problems[1].pk.value, "404")
unitTest:assertEquals(problems[2].pk.value, "448")
unitTest:assertEquals(problems[3].pk.value, "607")
unitTest:assertEquals(problems[4].pk.value, "640")
unitTest:assertEquals(problems[5].pk.value, "763")

problems = TerraLib().checkLayerGeometries(proj, l1Name, fix)

unitTest:assertEquals(#problems, 0)

l1File:delete()
proj.file:delete()
end
Expand Down

0 comments on commit 779efd1

Please sign in to comment.