Skip to content

Commit

Permalink
corrections TerraME#2334.
Browse files Browse the repository at this point in the history
  • Loading branch information
avancinirodrigo committed Mar 26, 2020
1 parent d7b75df commit 112579b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
19 changes: 6 additions & 13 deletions packages/base/lua/CellularSpace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ local function setCellsByTerraLibDataSet(self, dSet, geom)

if geom then
for k, v in pairs(dSet[i]) do
if (k == geom.name) then
if k == geom.name then
if self.geometry then
cell.geom = gis.TerraLib().castGeomToSubtype(v)
end
Expand Down Expand Up @@ -1366,22 +1366,15 @@ CellularSpace_ = {
mandatoryArgument(1, "string", newLayerName)

local dset = gis.TerraLib().getDataSet{project = self.project, layer = self.layer.name, missing = self.missing}
local geomAttrName = self.layer.geometry
if not self.geometry then
for i = 0, #dset do
for k, v in pairs(dset[i]) do
if (k == "OGR_GEOMETRY") or (k == "geom") or (k == "ogr_geometry") then
self.cells[i + 1][k] = v
end
end
self.cells[i + 1][geomAttrName] = dset[i][geomAttrName]
end
elseif dset[0].OGR_GEOMETRY or dset[0].ogr_geometry then
elseif dset[0][geomAttrName] then
for i = 0, #dset do
for k, v in pairs(dset[i]) do
if (k == "OGR_GEOMETRY") or (k == "ogr_geometry") then
self.cells[i + 1].geom = nil
self.cells[i + 1][k] = v
end
end
self.cells[i + 1].geom = nil
self.cells[i + 1][geomAttrName] = dset[i][geomAttrName]
end
end

Expand Down
4 changes: 2 additions & 2 deletions packages/base/tests/database/basics/CellularSpace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ return{

forEachCell(cs, function(c)
unitTest:assertNotNil(c.geom)
unitTest:assertNil(c.OGR_GEOMETRY)
unitTest:assertNotNil(c[layer1.geometry])
end)

cs = CellularSpace{
Expand All @@ -199,7 +199,7 @@ return{

forEachCell(cs, function(c)
unitTest:assertNil(c.geom)
unitTest:assertNil(c.OGR_GEOMETRY)
unitTest:assertNil(c[layer1.geometry])
end)

unitTest:assertEquals(303, #cs.cells)
Expand Down
4 changes: 2 additions & 2 deletions packages/base/tests/functional/basics/CellularSpace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ return{

forEachCell(cs, function(c)
unitTest:assertNil(c.geom)
unitTest:assertNil(c.OGR_GEOMETRY)
unitTest:assertNil(c[layer.geometry])
end)

cs = CellularSpace{
Expand All @@ -261,7 +261,7 @@ return{

forEachCell(cs, function(c)
unitTest:assertNil(c.geom)
unitTest:assertNil(c.OGR_GEOMETRY)
unitTest:assertNil(c[layer.geometry])
end)

proj.file:delete()
Expand Down

0 comments on commit 112579b

Please sign in to comment.