Circle processor

Converts circle definitions of shapes to regular polygons which approximate them.

Table 5. Circle Processor Options

NameRequiredDefaultDescription

field

yes

-

The string-valued field to trim whitespace from

target_field

no

field

The field to assign the polygon shape to, by default field is updated in-place

ignore_missing

no

false

If true and field does not exist, the processor quietly exits without modifying the document

error_distance

yes

-

The difference between the resulting inscribed distance from center to side and the circle’s radius (measured in meters for geo_shape, unit-less for shape)

shape_type

yes

-

which field mapping type is to be used when processing the circle: geo_shape or shape

if

no

-

Conditionally execute this processor.

on_failure

no

-

Handle failures for this processor. See Handling Failures in Pipelines.

ignore_failure

no

false

Ignore failures for this processor. See Handling Failures in Pipelines.

tag

no

-

An identifier for this processor. Useful for debugging and metrics.

error distance

  1. PUT circles
  2. {
  3. "mappings": {
  4. "properties": {
  5. "circle": {
  6. "type": "geo_shape"
  7. }
  8. }
  9. }
  10. }
  11. PUT _ingest/pipeline/polygonize_circles
  12. {
  13. "description": "translate circle to polygon",
  14. "processors": [
  15. {
  16. "circle": {
  17. "field": "circle",
  18. "error_distance": 28.0,
  19. "shape_type": "geo_shape"
  20. }
  21. }
  22. ]
  23. }

Using the above pipeline, we can attempt to index a document into the circles index. The circle can be represented as either a WKT circle or a GeoJSON circle. The resulting polygon will be represented and indexed using the same format as the input circle. WKT will be translated to a WKT polygon, and GeoJSON circles will be translated to GeoJSON polygons.

Example: Circle defined in Well Known Text

In this example a circle defined in WKT format is indexed

  1. PUT circles/_doc/1?pipeline=polygonize_circles
  2. {
  3. "circle": "CIRCLE (30 10 40)"
  4. }
  5. GET circles/_doc/1

The response from the above index request:

  1. {
  2. "found": true,
  3. "_index": "circles",
  4. "_type": "_doc",
  5. "_id": "1",
  6. "_version": 1,
  7. "_seq_no": 22,
  8. "_primary_term": 1,
  9. "_source": {
  10. "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))"
  11. }
  12. }

Example: Circle defined in GeoJSON

In this example a circle defined in GeoJSON format is indexed

  1. PUT circles/_doc/2?pipeline=polygonize_circles
  2. {
  3. "circle": {
  4. "type": "circle",
  5. "radius": "40m",
  6. "coordinates": [30, 10]
  7. }
  8. }
  9. GET circles/_doc/2

The response from the above index request:

  1. {
  2. "found": true,
  3. "_index": "circles",
  4. "_type": "_doc",
  5. "_id": "2",
  6. "_version": 1,
  7. "_seq_no": 22,
  8. "_primary_term": 1,
  9. "_source": {
  10. "circle": {
  11. "coordinates": [
  12. [
  13. [30.000365257263184, 10.0],
  14. [30.000111397193788, 10.00034284530941],
  15. [29.999706043744222, 10.000213571721195],
  16. [29.999706043744222, 9.999786428278805],
  17. [30.000111397193788, 9.99965715469059],
  18. [30.000365257263184, 10.0]
  19. ]
  20. ],
  21. "type": "Polygon"
  22. }
  23. }
  24. }

Notes on Accuracy

Accuracy of the polygon that represents the circle is defined as error_distance. The smaller this difference is, the closer to a perfect circle the polygon is.

Below is a table that aims to help capture how the radius of the circle affects the resulting number of sides of the polygon given different inputs.

The minimum number of sides is 4 and the maximum is 1000.

Table 6. Circle Processor Accuracy

error_distanceradius in metersnumber of sides of polygon

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