circle.asciidoc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. ==== Example: Circle defined in Well Known Text
  53. In this example a circle defined in WKT format is indexed
  54. [source,console]
  55. --------------------------------------------------
  56. PUT circles/_doc/1?pipeline=polygonize_circles
  57. {
  58. "circle": "CIRCLE (30 10 40)"
  59. }
  60. GET circles/_doc/1
  61. --------------------------------------------------
  62. // TEST[continued]
  63. The response from the above index request:
  64. [source,console-result]
  65. --------------------------------------------------
  66. {
  67. "found": true,
  68. "_index": "circles",
  69. "_id": "1",
  70. "_version": 1,
  71. "_seq_no": 22,
  72. "_primary_term": 1,
  73. "_source": {
  74. "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))"
  75. }
  76. }
  77. --------------------------------------------------
  78. // TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term": 1/"_primary_term" : $body._primary_term/]
  79. ==== Example: Circle defined in GeoJSON
  80. In this example a circle defined in GeoJSON format is indexed
  81. [source,console]
  82. --------------------------------------------------
  83. PUT circles/_doc/2?pipeline=polygonize_circles
  84. {
  85. "circle": {
  86. "type": "circle",
  87. "radius": "40m",
  88. "coordinates": [30, 10]
  89. }
  90. }
  91. GET circles/_doc/2
  92. --------------------------------------------------
  93. // TEST[continued]
  94. The response from the above index request:
  95. [source,console-result]
  96. --------------------------------------------------
  97. {
  98. "found": true,
  99. "_index": "circles",
  100. "_id": "2",
  101. "_version": 1,
  102. "_seq_no": 22,
  103. "_primary_term": 1,
  104. "_source": {
  105. "circle": {
  106. "coordinates": [
  107. [
  108. [30.000365257263184, 10.0],
  109. [30.000111397193788, 10.00034284530941],
  110. [29.999706043744222, 10.000213571721195],
  111. [29.999706043744222, 9.999786428278805],
  112. [30.000111397193788, 9.99965715469059],
  113. [30.000365257263184, 10.0]
  114. ]
  115. ],
  116. "type": "Polygon"
  117. }
  118. }
  119. }
  120. --------------------------------------------------
  121. // TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term": 1/"_primary_term" : $body._primary_term/]
  122. [[circle-processor-notes]]
  123. ==== Notes on Accuracy
  124. Accuracy of the polygon that represents the circle is defined as `error_distance`. The smaller this
  125. difference is, the closer to a perfect circle the polygon is.
  126. Below is a table that aims to help capture how the radius of the circle affects the resulting number of sides
  127. of the polygon given different inputs.
  128. The minimum number of sides is `4` and the maximum is `1000`.
  129. [[circle-processor-accuracy]]
  130. .Circle Processor Accuracy
  131. [options="header"]
  132. |======
  133. | error_distance | radius in meters | number of sides of polygon
  134. | 1.00 | 1.0 | 4
  135. | 1.00 | 10.0 | 14
  136. | 1.00 | 100.0 | 45
  137. | 1.00 | 1000.0 | 141
  138. | 1.00 | 10000.0 | 445
  139. | 1.00 | 100000.0 | 1000
  140. |======