跳转至

Parse KML string as geometry(将KML字符串解析为几何图形(Parse KML string as geometry))

Supported in: Batch, Streaming

Parses KML geometry definitions as a GeoJSON. Ignores all attributes. This expression operates on already extracted text; please extract files to text before using this expression.

Expression categories: Geospatial

Declared arguments

  • KML string to parse: Valid KML string to parse to geometry.
    Expression\
  • optional Output mode: Choose whether to output null on an erroneous output, or a result type from which you can extract the 'ok' field to get the geometry or the 'error' field to get a descriptive error message.
    Enum\
  • optional Prepare geometry after parse: Choose whether the kml should be prepared to adhere to Foundry geometry semantics. Geometries should be prepared prior to ingestion into the ontology to prevent failures during ontology indexing. Running prepare may result in more errors during the parse itself. For example, prepare will error on geometries with out of bounds coordinates during indexing.
    Expression\

Output type: String | Struct\

Examples

Example 1: Base case

Description: Basic polygons.

Argument values:

  • KML string to parse: col
  • Output mode: null
  • Prepare geometry after parse: null
col Output
\
\
-71.1663,42.2614
-71.1667,42.2616
\

\
{"type":"LineString","coordinates":[[-71.1663,42.2614],[-71.1667,42.2616]]}
\
\1\
\relativeToGround\
\<ou...
{"type":"Polygon","coordinates":[[[-122.0848938459612,37.42257124044786,17.0],[-122.0847882750515,37...
\
\1\
\relativeToGround\
\<ou...
{"type":"Polygon","coordinates":[[[-77.05465973756702,38.87291016281703,100.0],[-77.0531553685479,38...
\
\
-71.1663,42.2614
\

\
{"type":"Point","coordinates":[-71.1663,42.2614]}
\
\
\
\ -71.1663,42.2614
-71.1...
{"type":"MultiPolygon","coordinates":[[[[-81.1679,32.2614],[-81.1679,32.28],[-81.1663,32.28],[-81.16...

Example 2: Base case

Description: Basic polygons with result type outputs.

Argument values:

  • KML string to parse: col
  • Output mode: with_errors
  • Prepare geometry after parse: null
col shouldPrepare Output
\
\
-71.1663,42.2614
-71.1667,42.2616
\

\
true {
error: null,
ok: {"type":"LineString","coordinates":[[-71.1663,42.2614],[-71.1667,42.2616]]},
}
\
\1\
\relativeToGround\
\<ou...
true {
error: null,
ok: {"type":"Polygon","coordinates":[[[-122.0848938459612,37.42257124044786,17.0],[-122.0847882750515,37...,
}
\
\1\
\relativeToGround\
\<ou...
true {
error: null,
ok: {"type":"Polygon","coordinates":[[[-77.05465973756702,38.87291016281703,100.0],[-77.0531553685479,38...,
}
\
\
-71.1663,42.2614
\

\
true {
error: null,
ok: {"type":"Point","coordinates":[-71.1663,42.2614]},
}
\
\
\
\ -71.1663,42.2614
-71.1...
true {
error: null,
ok: {"type":"MultiPolygon","coordinates":[[[[-81.1679,32.2614],[-81.1679,32.28],[-81.1663,32.28],[-81.16...,
}

Example 3: Base case

Description: Full KML files with documents and folders are not supported.

Argument values:

  • KML string to parse: col
  • Output mode: null
  • Prepare geometry after parse: null
col Output
\
\
\KML Samples\
<...
null

Example 4: Null case

Description: Example of null input.

Argument values:

  • KML string to parse: col
  • Output mode: null
  • Prepare geometry after parse: null
col Output
null null
empty string null

Example 5: Edge case

Description: Invalid KML examples.

Argument values:

  • KML string to parse: col
  • Output mode: null
  • Prepare geometry after parse: null
col Output
\\ formed KML \\ null
\
\1\
\relativeToGround\
\<ou...
null
\\\
\ -123.0,37.0,17
-122.0,38.0,17
...
null

Example 6: Edge case

Description: Invalid KML examples with out-of-bounds coordinates

Argument values:

  • KML string to parse: col
  • Output mode: null
  • Prepare geometry after parse: null
col Output
\\\
\ -180.3348783983763,95.1514008468736,...
null

Example 7: Edge case

Description: Invalid KML examples with out-of-bounds coordinates when prepare geometry is not run will return a geometry.

Argument values:

  • KML string to parse: col
  • Output mode: simple
  • Prepare geometry after parse: shouldPrepare
col shouldPrepare Output
\\\
\ -180.3348783983763,95.1514008468736,...
false {"coordinates":[[[-180.3348783983763,95.1514008468736,100.0],[-180.3372535345629,95.14888517553887,1...


中文翻译

将KML字符串解析为几何图形(Parse KML string as geometry)

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

将KML几何定义解析为GeoJSON。忽略所有属性。此表达式作用于已提取的文本;请在使用此表达式前将文件提取为文本。

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

声明的参数

  • 要解析的KML字符串(KML string to parse): 要解析为几何图形的有效KML字符串。
    表达式\
  • 可选 输出模式(Output mode): 选择在错误输出时返回null,还是返回一个结果类型,从中可以提取'ok'字段获取几何图形,或提取'error'字段获取描述性错误信息。
    枚举\
  • 可选 解析后准备几何图形(Prepare geometry after parse): 选择是否准备KML以符合Foundry几何语义。在将几何图形导入本体论(Ontology)之前应进行准备,以防止本体索引期间失败。运行准备操作可能导致解析过程中出现更多错误。例如,在索引过程中,准备操作会对坐标越界的几何图形报错。
    表达式\

输出类型: String | Struct\

示例

示例1:基本情况

描述: 基本多边形。

参数值:

  • 要解析的KML字符串: col
  • 输出模式: null
  • 解析后准备几何图形: null
col 输出(Output)
\
\
-71.1663,42.2614
-71.1667,42.2616
\

\
{"type":"LineString","coordinates":[[-71.1663,42.2614],[-71.1667,42.2616]]}
\
\1\
\relativeToGround\
\<ou...
{"type":"Polygon","coordinates":[[[-122.0848938459612,37.42257124044786,17.0],[-122.0847882750515,37...
\
\1\
\relativeToGround\
\<ou...
{"type":"Polygon","coordinates":[[[-77.05465973756702,38.87291016281703,100.0],[-77.0531553685479,38...
\
\
-71.1663,42.2614
\

\
{"type":"Point","coordinates":[-71.1663,42.2614]}
\
\
\
\ -71.1663,42.2614
-71.1...
{"type":"MultiPolygon","coordinates":[[[[-81.1679,32.2614],[-81.1679,32.28],[-81.1663,32.28],[-81.16...

示例2:基本情况

描述: 带结果类型输出的基本多边形。

参数值:

  • 要解析的KML字符串: col
  • 输出模式: with_errors
  • 解析后准备几何图形: null
col shouldPrepare 输出(Output)
\
\
-71.1663,42.2614
-71.1667,42.2616
\

\
true {
error: null,
ok: {"type":"LineString","coordinates":[[-71.1663,42.2614],[-71.1667,42.2616]]},
}
\
\1\
\relativeToGround\
\<ou...
true {
error: null,
ok: {"type":"Polygon","coordinates":[[[-122.0848938459612,37.42257124044786,17.0],[-122.0847882750515,37...,
}
\
\1\
\relativeToGround\
\<ou...
true {
error: null,
ok: {"type":"Polygon","coordinates":[[[-77.05465973756702,38.87291016281703,100.0],[-77.0531553685479,38...,
}
\
\
-71.1663,42.2614
\

\
true {
error: null,
ok: {"type":"Point","coordinates":[-71.1663,42.2614]},
}
\
\
\
\ -71.1663,42.2614
-71.1...
true {
error: null,
ok: {"type":"MultiPolygon","coordinates":[[[[-81.1679,32.2614],[-81.1679,32.28],[-81.1663,32.28],[-81.16...,
}

示例3:基本情况

描述: 不支持包含文档和文件夹的完整KML文件。

参数值:

  • 要解析的KML字符串: col
  • 输出模式: null
  • 解析后准备几何图形: null
col 输出(Output)
\
\
\KML Samples\
<...
null

示例4:空值情况

描述: 空值输入示例。

参数值:

  • 要解析的KML字符串: col
  • 输出模式: null
  • 解析后准备几何图形: null
col 输出(Output)
null null
空字符串 null

示例5:边界情况

描述: 无效KML示例。

参数值:

  • 要解析的KML字符串: col
  • 输出模式: null
  • 解析后准备几何图形: null
col 输出(Output)
\\ formed KML \\ null
\
\1\
\relativeToGround\
\<ou...
null
\\\
\ -123.0,37.0,17
-122.0,38.0,17
...
null

示例6:边界情况

描述: 坐标越界的无效KML示例。

参数值:

  • 要解析的KML字符串: col
  • 输出模式: null
  • 解析后准备几何图形: null
col 输出(Output)
\\\
\ -180.3348783983763,95.1514008468736,...
null

示例7:边界情况

描述: 当不运行准备几何图形时,坐标越界的无效KML示例将返回一个几何图形。

参数值:

  • 要解析的KML字符串: col
  • 输出模式: simple
  • 解析后准备几何图形: shouldPrepare
col shouldPrepare 输出(Output)
\\\
\ -180.3348783983763,95.1514008468736,...
false {"coordinates":[[[-180.3348783983763,95.1514008468736,100.0],[-180.3372535345629,95.14888517553887,1...