圆形处理器
编辑圆形处理器
编辑将形状的圆形定义转换为逼近它们的规则多边形。
表 6. 圆形处理器选项
名称 | 必需 | 默认值 | 描述 |
---|---|---|---|
|
是 |
- |
要解释为圆形的字段。可以是 WKT 格式的字符串,也可以是 GeoJSON 的映射。 |
|
否 |
|
要将多边形形状分配到的字段,默认情况下 |
|
否 |
|
如果 |
|
是 |
- |
从中心到边的结果内切距离与圆的半径之间的差值(对于 |
|
是 |
- |
处理圆形时要使用的字段映射类型: |
|
否 |
- |
处理器的描述。用于描述处理器的目的或其配置。 |
|
否 |
- |
有条件地执行处理器。请参阅有条件地运行处理器。 |
|
否 |
|
忽略处理器的失败。请参阅处理管道失败。 |
|
否 |
- |
处理处理器的失败。请参阅处理管道失败。 |
|
否 |
- |
处理器的标识符。用于调试和指标。 |
resp = client.indices.create( index="circles", mappings={ "properties": { "circle": { "type": "geo_shape" } } }, ) print(resp) resp1 = client.ingest.put_pipeline( id="polygonize_circles", description="translate circle to polygon", processors=[ { "circle": { "field": "circle", "error_distance": 28, "shape_type": "geo_shape" } } ], ) print(resp1)
response = client.indices.create( index: 'circles', body: { mappings: { properties: { circle: { type: 'geo_shape' } } } } ) puts response response = client.ingest.put_pipeline( id: 'polygonize_circles', body: { description: 'translate circle to polygon', processors: [ { circle: { field: 'circle', error_distance: 28, shape_type: 'geo_shape' } } ] } ) puts response
const response = await client.indices.create({ index: "circles", mappings: { properties: { circle: { type: "geo_shape", }, }, }, }); console.log(response); const response1 = await client.ingest.putPipeline({ id: "polygonize_circles", description: "translate circle to polygon", processors: [ { circle: { field: "circle", error_distance: 28, shape_type: "geo_shape", }, }, ], }); console.log(response1);
PUT circles { "mappings": { "properties": { "circle": { "type": "geo_shape" } } } } PUT _ingest/pipeline/polygonize_circles { "description": "translate circle to polygon", "processors": [ { "circle": { "field": "circle", "error_distance": 28.0, "shape_type": "geo_shape" } } ] }
使用上述管道,我们可以尝试将文档索引到 circles
索引中。圆形可以用 WKT 圆或 GeoJSON 圆表示。生成的多边形将使用与输入圆形相同的格式表示和索引。WKT 将转换为 WKT 多边形,而 GeoJSON 圆形将转换为 GeoJSON 多边形。
不支持包含极点的圆形。
示例:以众所周知的文本定义的圆形
编辑在此示例中,索引了以 WKT 格式定义的圆形
resp = client.index( index="circles", id="1", pipeline="polygonize_circles", document={ "circle": "CIRCLE (30 10 40)" }, ) print(resp) resp1 = client.get( index="circles", id="1", ) print(resp1)
response = client.index( index: 'circles', id: 1, pipeline: 'polygonize_circles', body: { circle: 'CIRCLE (30 10 40)' } ) puts response response = client.get( index: 'circles', id: 1 ) puts response
const response = await client.index({ index: "circles", id: 1, pipeline: "polygonize_circles", document: { circle: "CIRCLE (30 10 40)", }, }); console.log(response); const response1 = await client.get({ index: "circles", id: 1, }); console.log(response1);
PUT circles/_doc/1?pipeline=polygonize_circles { "circle": "CIRCLE (30 10 40)" } GET circles/_doc/1
上述索引请求的响应
{ "found": true, "_index": "circles", "_id": "1", "_version": 1, "_seq_no": 22, "_primary_term": 1, "_source": { "circle": "POLYGON ((30.000365257263184 10.0, 30.000111397193788 10.00034284530941, 29.999706043744222 10.000213571721195, 29.999706043744222 9.999786428278805, 30.000111397193788 9.99965715469059, 30.000365257263184 10.0))" } }
示例:以 GeoJSON 定义的圆形
编辑在此示例中,索引了以 GeoJSON 格式定义的圆形
resp = client.index( index="circles", id="2", pipeline="polygonize_circles", document={ "circle": { "type": "circle", "radius": "40m", "coordinates": [ 30, 10 ] } }, ) print(resp) resp1 = client.get( index="circles", id="2", ) print(resp1)
response = client.index( index: 'circles', id: 2, pipeline: 'polygonize_circles', body: { circle: { type: 'circle', radius: '40m', coordinates: [ 30, 10 ] } } ) puts response response = client.get( index: 'circles', id: 2 ) puts response
const response = await client.index({ index: "circles", id: 2, pipeline: "polygonize_circles", document: { circle: { type: "circle", radius: "40m", coordinates: [30, 10], }, }, }); console.log(response); const response1 = await client.get({ index: "circles", id: 2, }); console.log(response1);
PUT circles/_doc/2?pipeline=polygonize_circles { "circle": { "type": "circle", "radius": "40m", "coordinates": [30, 10] } } GET circles/_doc/2
上述索引请求的响应
{ "found": true, "_index": "circles", "_id": "2", "_version": 1, "_seq_no": 22, "_primary_term": 1, "_source": { "circle": { "coordinates": [ [ [30.000365257263184, 10.0], [30.000111397193788, 10.00034284530941], [29.999706043744222, 10.000213571721195], [29.999706043744222, 9.999786428278805], [30.000111397193788, 9.99965715469059], [30.000365257263184, 10.0] ] ], "type": "Polygon" } } }
关于准确性的说明
编辑表示圆形的 多边形的准确性定义为 error_distance
。此差值越小,多边形就越接近完美的圆形。
下表旨在帮助捕获在给定不同输入的情况下,圆的半径如何影响多边形的边数。
最小边数为 4
,最大边数为 1000
。