Utils

Some basic and useful functions to handle file names.

Functions

forEachLayer  Second order function to traverse all the Layers of a given Project, applying a given function to each of its Layer.

forEachLayer 

Second order function to traverse all the Layers of a given Project, applying a given function to each of its Layer. If any of the function calls returns false, forEachLayer() stops and returns false, otherwise it returns true.

Arguments

  • #1: A Project.
  • #2: A user-defined function that takes a Layer as argument. It can optionally have a second argument with a positive number representing the position of the Layer in the vector of Cells. If it returns false when processing a given Layer, forEachLayer() stops and does not process any other Cell.

Usage

import("terralib")

filename = "emas-count.tview"

project = Project{
    file = filename,
    clean = true,
    author = "Almeida, R.",
    title = "Emas database",
    firebreak = filePath("emas-firebreak.shp", "terralib"),
    river = filePath("emas-river.shp", "terralib"),
    limit = filePath("emas-limit.shp", "terralib")
}

forEachLayer(project, function(layer, index)
    print(index.."\t"..layer.rep)
end)

File(filename):deleteIfExists()

This webpage was automatically created using TerraME.