变量 'line' 在哪里声明?

Where is the variable 'line' declared?

我在 Google Earth Engine 上获得了下面的脚本,用于沿样带提取数据。 (https://code.earthengine.google.com/e31179d9e7143235092d6b4fa29a12fd)在GEE代码编辑器中,scipt的顶部有一个导入标志(附图片)。

对'line'进行了多次引用,我理解为已声明的变量,但找不到。我查看了 GEE 文档,并在 JavaScript 参考中确定它是一种方法还是类似的方法,但我无法解决。

导入的数据声明为'transect',所以不是

/***
 * Reduces image values along the given line string geometry using given reducer.
 * 
 * Samples image values using image native scale, or opt_scale
 */
function reduceImageProfile(image, line, reducer, scale, crs) {
  var length = line.length();
  var distances = ee.List.sequence(0, length, scale)
  var lines = line.cutLines(distances, ee.Number(scale).divide(5)).geometries();
  lines = lines.zip(distances).map(function(l) { 
    l = ee.List(l)
    
    var geom = ee.Geometry(l.get(0))
    var distance = ee.Number(l.get(1))
    
    geom = ee.Geometry.LineString(geom.coordinates())
    
    return ee.Feature(geom, {distance: distance})
  })
  lines = ee.FeatureCollection(lines)

  // reduce image for every segment
  var values = image.reduceRegions( {
    collection: ee.FeatureCollection(lines), 
    reducer: reducer, 
    scale: scale, 
    crs: crs
  })
  
  return values
}


// Define a line across the Olympic Peninsula, USA.

// Import a digital surface model and add latitude and longitude bands.
var elevImg = ee.Image('JAXA/ALOS/AW3D30/V2_2').select('AVE_DSM');

var profile = reduceImageProfile(elevImg, transect, ee.Reducer.mean(), 100)

print(ui.Chart.feature.byFeature(profile, 'distance', ['mean']))

line 不是一个变量,它是一个 参数 。参数与函数内的局部变量非常相似,但它们不是用 varletconst 声明的,而是在函数的参数列表中声明的:

function reduceImageProfile(image, line, reducer, scale, crs) {
// here −−−−−−−−−−−−−−−−−−−−−−−−−−−^

每次调用函数时使用函数调用中相应的参数填充参数的值。让我们举一个更简单的例子:

function example(a, b) {
//               ^−−^−−−−−−−−−− parameter declarations
    return a + b;
}

//                  vv−−−−−−−−− argument for `a`
console.log(example(40, 2));
//                      ^−−−−−− argument for `b`

//                  vv−−−−−−−−− argument for `a`
console.log(example(60, 7));
//                      ^−−−−−− argument for `b`

在第一次调用 example 时,a 参数从调用中接收值 40b 参数接收值 2争论。在第二次调用中,a 参数接收值 60b 参数从调用参数接收值 7