TerraME / terrame

TerraME is a programming environment for spatial dynamical modelling
www.terrame.org
GNU Lesser General Public License v3.0
35 stars 13 forks source link

Error in cell area function #2371

Closed avancinirodrigo closed 3 years ago

avancinirodrigo commented 3 years ago

Cell:area() function is returning always the same value. For cellular space, it works fine, but for common spatial data, it is not working.

TerraLib getArea() function is wrong as well.

    getArea = function(geom)
        local geomType = geom:getGeometryType()

        if (geomType == "MultiPolygon") or (geomType == "CurvePolygon") or
            (geomType == "Polygon") then
            local env = geom:getMBR()
            return env:getArea() -->>> correct is geom:getArea(), not env:getArea()
        else
            customWarning("Geometry should be a polygon to get the area.")
        end

        return 0
    end,