跳转至

Nth point in linestring(线串中的第N个点(Nth point in linestring))

Supported in: Batch, Faster, Streaming

Returns the nth point in a single linestring in the geometry. Indexing is 1-based, and an index of 0 is out-of-bounds. A negative index is counted backwards from the end of the linestring, so that -1 is the last point. Returns null for any of the following conditions: geometry isn't a single linestring, a feature collection or geometry collection is provided, index is out-of-bounds, or at least one argument is null.

Expression categories: Geospatial

Declared arguments

  • Linestring: Linestring to retrieve the nth point of.
    Expression\
  • N: Index of the point to retrieve. Indexing is 1-based, and an index of 0 is out-of-bounds. A negative index is counted backwards from the end of the linestring, so that -1 is the last point.
    Expression\

Output type: GeoPoint

Examples

Example 1: Base case

Argument values:

  • Linestring: linestring
  • N: n
linestring n Output
{"type":"LineString","coordinates":[[30.0,2.0],[35.0,0.0],[50.0,3.0]]} 1 {
latitude: 2.0,
longitude: 30.0,
}
{"type":"LineString","coordinates":[[30.0,2.0],[35.0,0.0],[50.0,3.0]]} 3 {
latitude: 3.0,
longitude: 50.0,
}
{"type":"LineString","coordinates":[[45.0,9.0],[90.0,4.0],[40.0,0.0]]} -1 {
latitude: 0.0,
longitude: 40.0,
}

Example 2: Null case

Argument values:

  • Linestring: linestring
  • N: n
linestring n Output
{"type":"LineString","coordinates":[[10.0,4.0],[75.0,0.0]]} null null
null 1 null

Example 3: Edge case

Argument values:

  • Linestring: linestring
  • N: n
linestring n Output
{"type":"MultiLineString","coordinates":[[[100.0,0.0]], [[102.0,2.0]]]} 2 null
{"type":"GeometryCollection","geometries":{"type":"LineString","coordinates":[[10.0,4.0]]}} 1 null
{"type":"LineString","coordinates":[[10.0,4.0],[75.0,0.0],[25.0,3.0]]} 0 null
{"type":"LineString","coordinates":[[12.0,3.0],[76.0,2.0],[98.0,8.0]]} 4 null
{"type":"LineString","coordinates":[[90.0,1.0],[34.0,1.0],[19.0,7.0]]} -4 null


中文翻译


线串中的第N个点(Nth point in linestring)

支持:批处理(Batch)、快速处理(Faster)、流处理(Streaming)

返回几何图形中单个线串的第N个点。索引从1开始,索引0表示越界。负索引从线串末尾向前计数,因此-1表示最后一个点。在以下任一情况下返回null:几何图形不是单个线串、提供了要素集合(feature collection)或几何集合(geometry collection)、索引越界,或至少有一个参数为null。

表达式类别: 地理空间(Geospatial)

声明的参数

  • Linestring(线串): 要从中获取第N个点的线串。
    表达式\
  • N: 要获取的点的索引。索引从1开始,索引0表示越界。负索引从线串末尾向前计数,因此-1表示最后一个点。
    表达式\

输出类型: GeoPoint

示例

示例1:基本情况

参数值:

  • Linestring: linestring
  • N: n
linestring n 输出
{"type":"LineString","coordinates":[[30.0,2.0],[35.0,0.0],[50.0,3.0]]} 1 {
latitude(纬度):2.0,
longitude(经度):30.0,
}
{"type":"LineString","coordinates":[[30.0,2.0],[35.0,0.0],[50.0,3.0]]} 3 {
latitude(纬度):3.0,
longitude(经度):50.0,
}
{"type":"LineString","coordinates":[[45.0,9.0],[90.0,4.0],[40.0,0.0]]} -1 {
latitude(纬度):0.0,
longitude(经度):40.0,
}

示例2:空值情况

参数值:

  • Linestring: linestring
  • N: n
linestring n 输出
{"type":"LineString","coordinates":[[10.0,4.0],[75.0,0.0]]} null null
null 1 null

示例3:边界情况

参数值:

  • Linestring: linestring
  • N: n
linestring n 输出
{"type":"MultiLineString","coordinates":[[[100.0,0.0]], [[102.0,2.0]]]} 2 null
{"type":"GeometryCollection","geometries":{"type":"LineString","coordinates":[[10.0,4.0]]}} 1 null
{"type":"LineString","coordinates":[[10.0,4.0],[75.0,0.0],[25.0,3.0]]} 0 null
{"type":"LineString","coordinates":[[12.0,3.0],[76.0,2.0],[98.0,8.0]]} 4 null
{"type":"LineString","coordinates":[[90.0,1.0],[34.0,1.0],[19.0,7.0]]} -4 null