circle.asciidoc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ingest-circle-processor]]
  4. === Circle processor
  5. ++++
  6. <titleabbrev>Circle</titleabbrev>
  7. ++++
  8. Converts circle definitions of shapes to regular polygons which approximate them.
  9. [[circle-processor-options]]
  10. .Circle Processor Options
  11. [options="header"]
  12. |======
  13. | Name | Required | Default | Description
  14. | `field` | yes | - | The string-valued field to trim whitespace from
  15. | `target_field` | no | `field` | The field to assign the polygon shape to, by default `field` is updated in-place
  16. | `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document
  17. | `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`)
  18. | `shape_type` | yes | - | which field mapping type is to be used when processing the circle: `geo_shape` or `shape`
  19. include::common-options.asciidoc[]
  20. |======
  21. image:images/spatial/error_distance.png[]
  22. [source,console]
  23. --------------------------------------------------
  24. PUT circles
  25. {
  26. "mappings": {
  27. "properties": {
  28. "circle": {
  29. "type": "geo_shape"
  30. }
  31. }
  32. }
  33. }
  34. PUT _ingest/pipeline/polygonize_circles
  35. {
  36. "description": "translate circle to polygon",
  37. "processors": [
  38. {
  39. "circle": {
  40. "field": "circle",
  41. "error_distance": 28.0,
  42. "shape_type": "geo_shape"
  43. }
  44. }
  45. ]
  46. }
  47. --------------------------------------------------
  48. Using the above pipeline, we can attempt to index a document into the `circles` index.
  49. The circle can be represented as either a WKT circle or a GeoJSON circle. The resulting
  50. polygon will be represented and indexed using the same format as the input circle. WKT will
  51. be translated to a WKT polygon, and GeoJSON circles will be translated to GeoJSON polygons.
  52. IMPORTANT: Circles that contain a pole are not supported.
  53. ==== Example: Circle defined in Well Known Text
  54. In this example a circle defined in WKT format is indexed
  55. [source,console]
  56. --------------------------------------------------
  57. PUT circles/_doc/1?pipeline=polygonize_circles
  58. {
  59. "circle": "CIRCLE (30 10 40)"
  60. }
  61. GET circles/_doc/1
  62. --------------------------------------------------
  63. // TEST[continued]
  64. The response from the above index request:
  65. [source,console-result]
  66. --------------------------------------------------
  67. {
  68. "found": true,
  69. "_index": "circles",
  70. "_id": "1",
  71. "_version": 1,
  72. "_seq_no": 22,
  73. "_primary_term": 1,
  74. "_source": {
  75. "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))"
  76. }
  77. }
  78. --------------------------------------------------
  79. // TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term": 1/"_primary_term" : $body._primary_term/]
  80. ==== Example: Circle defined in GeoJSON
  81. In this example a circle defined in GeoJSON format is indexed
  82. [source,console]
  83. --------------------------------------------------
  84. PUT circles/_doc/2?pipeline=polygonize_circles
  85. {
  86. "circle": {
  87. "type": "circle",
  88. "radius": "40m",
  89. "coordinates": [30, 10]
  90. }
  91. }
  92. GET circles/_doc/2
  93. --------------------------------------------------
  94. // TEST[continued]
  95. The response from the above index request:
  96. [source,console-result]
  97. --------------------------------------------------
  98. {
  99. "found": true,
  100. "_index": "circles",
  101. "_id": "2",
  102. "_version": 1,
  103. "_seq_no": 22,
  104. "_primary_term": 1,
  105. "_source": {
  106. "circle": {
  107. "coordinates": [
  108. [
  109. [30.000365257263184, 10.0],
  110. [30.000111397193788, 10.00034284530941],
  111. [29.999706043744222, 10.000213571721195],
  112. [29.999706043744222, 9.999786428278805],
  113. [30.000111397193788, 9.99965715469059],
  114. [30.000365257263184, 10.0]
  115. ]
  116. ],
  117. "type": "Polygon"
  118. }
  119. }
  120. }
  121. --------------------------------------------------
  122. // TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term": 1/"_primary_term" : $body._primary_term/]
  123. [[circle-processor-notes]]
  124. ==== Notes on Accuracy
  125. Accuracy of the polygon that represents the circle is defined as `error_distance`. The smaller this
  126. difference is, the closer to a perfect circle the polygon is.
  127. Below is a table that aims to help capture how the radius of the circle affects the resulting number of sides
  128. of the polygon given different inputs.
  129. The minimum number of sides is `4` and the maximum is `1000`.
  130. [[circle-processor-accuracy]]
  131. .Circle Processor Accuracy
  132. [options="header"]
  133. |======
  134. | error_distance | radius in meters | number of sides of polygon
  135. | 1.00 | 1.0 | 4
  136. | 1.00 | 10.0 | 14
  137. | 1.00 | 100.0 | 45
  138. | 1.00 | 1000.0 | 141
  139. | 1.00 | 10000.0 | 445
  140. | 1.00 | 100000.0 | 1000
  141. |======