Процессор Circle
Преобразует определения кругов форм в правильные многоугольники, которые их приближают.
Таблица 6. Параметры процессора Circle
| Имя | Обязательно | По умолчанию | Описание |
|---|---|---|---|
| да | - | Поле для интерпретации как круга. Либо строка в формате 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-многоугольники.
Круги, содержащие полюс, не поддерживаются.
Пример: Определение круга в формате Well Known Text
В данном примере индексируется круг, определённый в формате 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.
Таблица 7. Точность процессора Circle
| error_distance | радиус в метрах | количество сторон многоугольника |
|---|---|---|
1.00 | 1.0 | 4 |
1.00 | 10.0 | 14 |
1.00 | 100.0 | 45 |
1.00 | 1000.0 | 141 |
1.00 | 10000.0 | 445 |
1.00 | 100000.0 | 1000 |
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ingest-circle-processor.html