circle.asciidoc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ingest-circle-processor]]
  4. === Circle Processor
  5. Converts circle definitions of shapes to regular polygons which approximate them.
  6. [[circle-processor-options]]
  7. .Circle Processor Options
  8. [options="header"]
  9. |======
  10. | Name | Required | Default | Description
  11. | `field` | yes | - | The string-valued field to trim whitespace from
  12. | `target_field` | no | `field` | The field to assign the polygon shape to, by default `field` is updated in-place
  13. | `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document
  14. | `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`)
  15. | `shape_type` | yes | - | which field mapping type is to be used when processing the circle: `geo_shape` or `shape`
  16. include::common-options.asciidoc[]
  17. |======
  18. image:images/spatial/error_distance.png[]
  19. [source,js]
  20. --------------------------------------------------
  21. PUT circles
  22. {
  23. "mappings": {
  24. "properties": {
  25. "circle": {
  26. "type": "geo_shape"
  27. }
  28. }
  29. }
  30. }
  31. PUT _ingest/pipeline/polygonize_circles
  32. {
  33. "description": "translate circle to polygon",
  34. "processors": [
  35. {
  36. "circle": {
  37. "field": "circle",
  38. "error_distance": 28.0,
  39. "shape_type": "geo_shape"
  40. }
  41. }
  42. ]
  43. }
  44. --------------------------------------------------
  45. // CONSOLE
  46. Using the above pipeline, we can attempt to index a document into the `circles` index.
  47. The circle can be represented as either a WKT circle or a GeoJSON circle. The resulting
  48. polygon will be represented and indexed using the same format as the input circle. WKT will
  49. be translated to a WKT polygon, and GeoJSON circles will be translated to GeoJSON polygons.
  50. ==== Example: Circle defined in Well Known Text
  51. In this example a circle defined in WKT format is indexed
  52. [source,js]
  53. --------------------------------------------------
  54. PUT circles/_doc/1?pipeline=polygonize_circles
  55. {
  56. "circle": "CIRCLE (30 10 40)"
  57. }
  58. GET circles/_doc/1
  59. --------------------------------------------------
  60. // CONSOLE
  61. // TEST[continued]
  62. The response from the above index request:
  63. [source,js]
  64. --------------------------------------------------
  65. {
  66. "found": true,
  67. "_index": "circles",
  68. "_type": "_doc",
  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,js]
  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. // CONSOLE
  94. // TEST[continued]
  95. The response from the above index request:
  96. [source,js]
  97. --------------------------------------------------
  98. {
  99. "found": true,
  100. "_index": "circles",
  101. "_type": "_doc",
  102. "_id": "2",
  103. "_version": 1,
  104. "_seq_no": 22,
  105. "_primary_term": 1,
  106. "_source": {
  107. "circle": {
  108. "coordinates": [
  109. [
  110. [30.000365257263184, 10.0],
  111. [30.000111397193788, 10.00034284530941],
  112. [29.999706043744222, 10.000213571721195],
  113. [29.999706043744222, 9.999786428278805],
  114. [30.000111397193788, 9.99965715469059],
  115. [30.000365257263184, 10.0]
  116. ]
  117. ],
  118. "type": "polygon"
  119. }
  120. }
  121. }
  122. --------------------------------------------------
  123. // TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term": 1/"_primary_term" : $body._primary_term/]
  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. |======